How to generate "editable" PDF programmatically in AEM forms OSGI

Avatar

Avatar

LittleBigFeet

Avatar

LittleBigFeet

LittleBigFeet

05-07-2017

Hi all,

I have a requirement to generate a editable PDF in AEM OSGI and send it back to the client program as part of the response.

I was able to send out a "flat PDF" back via Output Service - generatePDFOutput mechanism. However this creates a flat pdf for the client program, which is not what we want.

My client needs to be able to call an endpoint with some xml data and needs to receive an editable pdf as part of response, so that when they send it to the end user, it can be edited by the end user according to their requirement.

Can some one provide some pointers on how i can archive this..

thanks...

View Entire Topic

Avatar

Avatar

user2062153

Avatar

user2062153

user2062153

13-07-2017

Hi,

Yes, you can use FormsService​ API for generating interactive PDF.

Sample code

byte[] xdpData = (data);

Document docData = new Document(xmlData);

PDFFormRenderOptions options = new PDFFormRenderOptions();

options.setContentRoot(xdpLocation); // location of XDP

Document docPDF = formsService.renderPDFForm(fileName,docData,options);

byte[] result = IOUtils.toByteArray(docPDF.getInputStream());