Using a Custom AEM Component to Display Generated PDF’s
Overview
Adobe Experience Manager Forms provides document-generation capabilities, including Interactive Communications and PDF Data Merge using XDP templates. These capabilities allow organizations to generate personalized PDF documents using data from different sources.
In many applications, users need to preview generated documents without downloading them or navigating away from the current page.
To address this requirement, we developed a reusable Embed PDF component that integrates with the Adobe PDF Embed API to display dynamically generated PDFs inline within an AEM page.
The component is built using standard AEM technologies, including HTL, Granite UI, JavaScript, and SCSS. It can be used on AEM Sites pages or integrated with Adaptive Forms.
This article explains how to obtain the component, deploy it to an AEM environment, configure it, and use it to display PDFs generated by AEM Forms.
We’ll demonstrate two supported document-generation workflows:
- Interactive Communications (IC): Generate personalized PDF documents using the AEM Communications REST API.
- PDF Data Merge: Generate PDF documents by merging XML data with XDP templates using AEM Forms Output Service.
The complete implementation is available in the companion GitHub repository.
What does the Embed PDF component do?
The Embed PDF component provides a configurable PDF preview experience within AEM pages.
It performs the following operations:
- Receives data from an application, form, or JavaScript function.
- Reads the PDF-generation configuration specified by the AEM author.
- Constructs the appropriate request payload.
- Invokes the configured PDF-generation endpoint.
- Displays a loading indicator while the document is generated.
- Receives the generated PDF as a binary response.
- Uses the Adobe PDF Embed API to display the document inline.
The component does not generate PDFs itself. It delegates generation to a configured backend service.
This separation allows the same component to support different document-generation workflows.
Prerequisites
Before integrating the component, ensure that you have:
- An AEM as a Cloud Service environment.
- An AEM project with the standard
ui.apps,ui.frontend, andcoremodules. - Access to Adobe Cloud Manager for deploying application code.
- An Adobe PDF Embed API Client ID.
- A configured PDF-generation endpoint that returns a PDF with the
application/pdfcontent type. - Appropriate AEM Forms capabilities if using Interactive Communications or PDF Data Merge.
For IC generation, the example implementation uses OAuth Server-to-Server authentication through an AEM Sling Servlet.
For Data Merge, the example implementation uses AEM Forms Output Service.