Generate Document Of Record (DOR) programmatically

This article illustrates the use of the com.adobe.aemds.guide.addon.dor.DoRService 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. Then we set the DoROptions.
  3. Then we invoke the render method of the DoRService and pass the DoROptions object to the render method

 

com.adobe.aemds.guide.addon.dor.DoRService dorService = sling.getService(com.adobe.aemds.guide.addon.dor.DoRService.class);
com.adobe.aemds.guide.addon.dor.DoROptions dorOptions =  new com.adobe.aemds.guide.addon.dor.DoROptions();
	dorOptions.setData(dataXml);
	dorOptions.setFormResource(resource);
	java.util.Locale locale = new java.util.Locale("en");
	dorOptions.setLocale(locale);
	com.adobe.aemds.guide.addon.dor.DoRResult 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. Download the package and install using package manager
  2. Create Service user 
  3. Point your browser to http://localhost:4502/useradmin
  4. Search for user "data"
  5. Double click the "data" user 
  6. Open the permissions tab
  7. Give Read, Modify and Create permissions on /content/usergenerated/content/aemformsenablement node
  8. Save your changes
  9. Open the form
  10. Fill out the form and click on "View PDF"
  11. You should see DOR in new tab in your browser

Download

Troubleshooting Tips

I do not see PDF displayed in new browser tab

  1. Make sure you are not blocking popups in your browser
  2. Make your you have followed the steps outlined in this article
  3. Make sure the "GetServiceUser" 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

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy