Show Menu

Using API to generate Document of Record in AEM Forms

Generate Document Of Record (DOR) programmatically
This article illustrates the use of the API to generate Document of Record programmatically. Document of Record is a PDF version of the data captured in Adaptive Form.
  1. The following is the code snippet. The first line gets the DOR Service.
  2. Set the DoROptions.
  3. Invoke the render method of the DoRService and pass the DoROptions object to the render method dorService = sling.getService(; dorOptions =  new;
 java.util.Locale locale = new java.util.Locale("en");
 dorOptions.setLocale(locale); dorResult = dorService.render(dorOptions);
 byte[] fileBytes = dorResult.getContent();
 com.adobe.aemfd.docmanager.Document dorDocument = new com.adobe.aemfd.docmanager.Document(fileBytes);

To try this on your local system, please follow the following steps
  1. Make sure you have installed and started the DevelopingWithServiceUser bundle provided as part of Create Service User article
  2. Search for Apache Sling Service User Mapper Service
  3. Make sure you the following entry DevelopingWithServiceUser.core:getformsresourceresolver=fd-service in the Service Mappings section
  4. Fill out the form and click on ' View PDF '
  5. You should see DOR in new tab in your browser
Troubleshooting Tips
PDF isn't displayed in new browser tab:
  1. Make sure you are not blocking popups in your browser
  2. Make you have followed the steps outlined in this article
  3. Make sure the 'DevelopingWithServiceUser' bundle is in active state
  4. Make sure the system user ' data ' has Read, Modify, and Create permissions on the following node /content/usergenerated/content/aemformsenablement