Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

XDP to PDF - OSGI OutputService

Avatar

Level 7

I need to run through a bunch of XDPs (on a filesystem) and convert them to flattened PDFs (for print).

We have AEM Forms (OSGI).

I have been reading here but, I cannot find any reference to OutputService.

https://experienceleague.adobe.com/docs/experience-manager-learn/forms/document-services/output-and-...

 

I am using the Adobe Archetype for creating custom Servlets, workflow components, etc.  I also have the the client sdk in my pom:

 <artifactId>aemfd-client-sdk</artifactId>
<groupId>com.adobe.aemfd</groupId>

 

Is there a quick tutorial that will show me how to use the OutputService to take an XDP and generate a PDF?

 

Thanks, 

1 Accepted Solution

Avatar

Correct answer by
Level 9

The output service is provided out of the box 

you can write a simple post wrapper as Shown in the link I sent earlier

View solution in original post

9 Replies

Avatar

Correct answer by
Level 9

The output service is provided out of the box 

you can write a simple post wrapper as Shown in the link I sent earlier

Avatar

Level 7
@Mayank_Gandhi - Nice to hear from you. I see this article but, this is using FormService and not OutputService. Also, it is for exporting data. I need a Java example to merge using Output. The documentation talks about POSTing to a Sample application. I am writing this in a Servlet so, I would rather not use a RESTful endpoint. I would rather write native Java code. Is there an example like that?

Avatar

Level 7
Actually, I downloaded the package from the documentation website and extracted the code. It is in the POST.jsp under .../AEMFormsAndSamples/Components/OutputService/POST.jsp

Avatar

Employee Advisor

@crich2784 Nice to hear from you as well. I might have a post jsp for forms service as well. Please msg me your email and I will send you the jsp.

Avatar

Level 7

@Mayank_Gandhi which library do I need to include in my project for FormsService?

In crx /libs/xfaforms/install

 

crich2784_0-1628608362373.png

 

Avatar

Level 4

By default XDP and input prefill data will be read as w3c dom document, you need to convert to AEMFD document using ByteArrayOutputStream, tranformfactory to inputstream and then return new com.adobe.aemfd.docmanager.Document(is)

public static Document createFlatPDF(String pathToXDP, com.adobe.aemfd.docmanager.Document xdp, com.adobe.aemfd.docmanager.Document data, OutputService outputService) {
Document outDoc = null;

outDoc = outputService.generatePDFOutput(xdp, data, getPDFOutputOptions(pathToXDP));
return outDoc;
}
public static PDFOutputOptions getPDFOutputOptions(String pathToXDP) {
PDFOutputOptions options = new PDFOutputOptions();
options.setContentRoot(pathToXDP);
options.setEmbedFonts(true);
return options;
}