Skip to main content

Digital Proposal generations using AEM Forms

article banner

Environment and domain details – AEM 6.5 On prem with Service Pack 12. Setup for Insurance domain. This document contains detailed steps to build and deploy an insurance project as a Proof of Concept from scratch. That can be used to generate a pdf based on agents input and can also insert marketing content in pdf by assembling multiple pdfs via sling servlet using output/ assembler service API of AEM Forms.

Step 1: Use following maven command to generate the project in batch mode:

mvn -B archetype:generate -DarchetypeGroupId=com.adobe.aem -DarchetypeArtifactId=aem-project-archetype -DarchetypeVersion=35 -DaemVersion="6.5.12" -DappTitle="CoforgeInsurancePoC" -DappId="CoforgeInsurancePoC" -DgroupId="com.CoforgeInsurancePoC" -Dversion="1.0.0" -DincludeFormsenrollment="y" -DincludeFormscommunications="y" -DincludeDispatcherConfig="n"

Note: aemVersion="6.5.12" after installing adobe-aemfd-win-pkg-6.0.640 package.

Build successful.

Step 2: Build and deploy the project code to a local instance of AEM Forms. While building the project will get “npm run mode” error.

To solve the issue make the following change

Go inside the folder-> ui.frontend-> package.json

Change typescript": "^3.3.3333" to "typescript": "^4.8.2"

Step 3: Build the project successfully

Command: mvn clean install –PautoInstallSinglePackage

Step 4: Import the project into eclipse to create a servlet for PDF creation. To use the adobe document manager for PDF creation, in eclipse you may face - com.adobe.aemfd.docmanager.Document import cannot be resolved issue.

To solve this, Go to main pom.xml and core pom.xml and add dependency.

com.adobe.aemfd
aemfd-client-sdk
6.0.772

Build the project once again to reflect the above change.

Step 5: Create PDF servlet

This servlet serves the purpose of creating a non-interactive pdf from an XML file that is mapped with XSD. XDP template is created in AEM Forms Designer for the pdf where all the dynamic field values will be populated from the XML file via servlet using AEM Document service, Output Service.

Output service is an OSGi service that is part of AEM Document Services. Output service supports various output formats and output design features of AEM Forms Designer. Output service can convert XFA templates and XML data to generate print documents in various formats.

generatePDFOutput operation of the Output service is used to generate a print document for each record.

Input properties:

Form: A document value that represents the form design. We can create form designs in Designer. Placed it in /content/dam/formsanddocuments/ with the template name “CoforgeTemplate.xdp”.

Input Data: A document value that specifies the data file that is merged with the form design. The data file that we provide is an XML file from file system.

Transformation Format/OutputOptions: A TransformationFormat value that specifies the format that the document is rendered to. A non-interactive PDF document is created.

Snippet of getting xml from file system and converting into document:

A class named “XmlParserData.java” is created to parse the xml file from the user to remove unwanted tags and pass the parsed xml as xml input.

Snippet of outputservice arguments – xdp template, xml data and outputOptions:

Step 6: Build the project: Go to command line and run - mvn clean install –PautoInstallSinglePackage.

Note: we assumed that your AEM Forms runs on port:4502, tweak pom.xml for required host and port details.

Step 7: Create PDF Assembler Service

The Assembler service let us combine, rearrange, and augment PDF and XDP documents and obtain information about PDF documents. Each job submitted to the Assembler service includes a Document Description XML (DDX) document, source documents.

Input Parameters:

1. DDX file: Document assembly produces a resultant document that contains the following content and characteristics:

  • All or part of each source document
  • All or part of the bookmarks from each source document, normalized for the assembled resultant document
  • Other characteristics adopted from the base document, including metadata, page labels, and page size

2. Two PDFs as input, PDF1 and PDF2 to merge into single pdf.

  • Snippet of Assembler Servlet:

Step 8: Generate PDF via Postman Client. Postman client can be download, and with basic auth it can be used to hit the AEM services.

Step 9: Assemble PDF via Postman client.

Step 9: Assemble PDF via Postman client.

Step 10: Generate pdf via adaptive form.

Fetch data button:

Store the xml data in location: /content/dam/formsanddocuments/coforge-insurance-demo/CoforgeXMLdata.xml.

On button click, all the form data will be filled. Rule for Fetch Data button is below

Generate PDF button:

On click of Generate PDF button it will hit the servlet for PDF creation. GuideBridge script for Generate PDF button is:

Assemble PDF Button:

Result:

Nitin Seth
Nitin Seth

Nitin is an accomplished Adobe Digital Professional having extensive experience in Customer Success & Centricity. He is a Digital Strategic & Transformation expert whose focus is to transform customer Digital Experience , As an IT Leader he ensures an interactive and collaborative way of digitizing the communication across channels. He has worked as a trusted advisor for the board level executives and stakeholders. He is in managing and delivering high-end solutions across geographies and industries for business partners and stake holders. He is having mindset with blend of business and sales experience to up-sell and cross-sell opportunities through the engagement to generate pipelines.

Related reads.

WHAT WE DO.

Explore our wide gamut of digital transformation capabilities and our work across industries.

Explore