Expand my Community achievements bar.

Form submission and generate pdf in AEM as cloud service

Avatar

Level 4



HI Team,
We have a requirement to update an HTML form, and upon submission, a PDF needs to be generated based on the form values. I have tried uploading the PDF to AEM DAM and was able to read the field values, but I am unable to update the PDF in AEM.

Which is the best approach to develop this feature ,


AEM as CS version 

Thanks in advance

6 Replies

Avatar

Level 6

Leveraging AEM Forms Add-On for PDF Generation

The AEM Forms Add-On provides built-in services and workflows to convert form data into PDFs effectively. If you plan to implement a custom solution, here are key considerations and steps:

Key Considerations for Custom Implementation in AEM

  •  Identify where the submitted form data is currently stored. CRX or external DB.
  • Handling Anonymous and Logged-In Users if the data is stored in CRX
    • For anonymous users:
      • Store the data under:
        /content/formname-data/anonymous/{submissionID}
    • For logged-in users:
      • Store the data under:
        /content/formname-data/{userID}/{submissionID}
  • You can create a component to configure the template for the PDF(e.g., headers, footers, body sections). This way we can reuse this for any other forms.
  • Create a service to generate PDFs dynamically from stored form data.

Avatar

Level 4

Customer is not planning to purchase AEM forms 

Avatar

Community Advisor

Hello @georhe6 ,

Instead of updating the pdf can't we generate the pdf using some library like (itextpdf) based on the submitted data? 

Thanks

Avatar

Level 4

Thanks @A_H_M_Imrul ,
Currently, the PDF  form contains certain predefined values, such as images and generic text. We have decided to use the PDF as a template and populate it with dynamic values using the iTextPDF API.

Avatar

Level 6

Hi @georhe6 ,

 

Updating a pdf programmatically means you will have to rely on Java libraries which can do them, refer - https://www.nutrient.io/blog/programmatically-editing-a-pdf-using-java . But they may be limited to some actions and may not fulfill what you are trying to achieve. 

I would recommend on creatin a new PDF every time a form is edited and delete the existing one, this of-course depends on how you create the naming of the pdf file. E.g. if its a customer form, I will create the pdf file based on firstName_lastname_randomId and then replace it when the values are updated .

 

Regards,

Anupam Patra

Avatar

Level 4

I was able to achieve this using itextpdf api, by passing the rendition of the pdf.