Expand my Community achievements bar.

SOLVED

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

Avatar

Level 3

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...

1 Accepted Solution

Avatar

Correct answer by
Level 2

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());

View solution in original post

4 Replies

Avatar

Employee

Hi,

Assuming that you are on AEM Forms 6.3 and by editable PDF you mean a PDF which can be field by client and data extracted and submitted to an end point upon submission (click of a button), you can use FormsService to generate an interactive PDF.

Hope it helps.

HTH,

Sufyan

Avatar

Level 3

Hi ..Thank you for your note...i think i was not clear enough .......Let me try to explain..

I have a third party CRM system, this system has the user data ...It will call an AEM endpoint and pass the customer data along with the form name. In AEM forms (Yes i am using 6.3)  i need some sort of api to merge the XDP along with the data sent, and create an editable pdf ( only the data supplied as part of the original request ) needs to be editable.

This editable pdf then needs to be sent back to CRM , and CRM routes it to the Customer, who might choose to either edit it or simply keep it as is and take a printout for it.

thank you..

Avatar

Level 3

Hi there, I went through Forms service, i think renderPDFForm is what i am looking for. I will give it a shot and see.

Any expert advise on this is welcome..

Thanks for your help..!!!

Avatar

Correct answer by
Level 2

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());