XDP to PDF - OSGI OutputService | Community
Skip to main content
crich2784
Level 6
July 26, 2021
Solved

XDP to PDF - OSGI OutputService

  • July 26, 2021
  • 5 replies
  • 2170 views

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, 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by GirishBedekar

The output service is provided out of the box 

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

5 replies

GirishBedekarAccepted solution
Level 8
July 27, 2021

The output service is provided out of the box 

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

crich2784
crich2784Author
Level 6
August 4, 2021
@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?
Mayank_Gandhi
Adobe Employee
Adobe Employee
August 9, 2021

@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
crich2784Author
Level 6
August 10, 2021

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

In crx /libs/xfaforms/install

 

 

manu-gupta
Level 4
August 13, 2021

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