Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

XDP to PDF - OSGI OutputService

crich2784
Level 5
Level 5

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
GirishBedekar
Correct answer by
Level 9
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
GirishBedekar
Correct answer by
Level 9
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

crich2784
Level 5
Level 5
@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?
crich2784
Level 5
Level 5
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
Mayank_Gandhi
Community Advisor
Community 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.

crich2784
Level 5
Level 5

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

In crx /libs/xfaforms/install

 

crich2784_0-1628608362373.png

 

manu-gupta
Level 3
Level 3

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;
}