Retrieve PDF page count from generatePdfOutput in AEM Forms JEE

Adobe Experience Manager (AEM) Forms JEE 6.5.23 doesn’t return the PDF page count directly from generatePdfOutput. To resolve the issue, use the Assembler service with the DocumentInformation DDX instruction and extract the page count from the resulting <NumPages> element.

Description description

Environment

Adobe Experience Manager (AEM) 6.5.23 Forms JEE (all supported platforms)

Issue/Symptoms

  • The generatePdfOutput operation returns the generated PDF but doesn’t provide its page count.
  • The page count must be retrieved programmatically for use in the JEE LiveCycle process.
  • No explicit error messages appear.

Root cause

The Output service in AEM Forms JEE doesn’t return the page count directly from generatePdfOutput. The Assembler service’s DocumentInformation DDX instruction provides a method to extract this information.

Resolution resolution

Follow the steps below to resolve the issue:

  1. After the Generate PDF Output step in the LiveCycle process, add an Assembler service step using Execute DDX / invokeDDX.

  2. Configure the DDX with the following instruction to extract the document information:

    code language-none
    <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
        <DocumentInformation source="generatedPdf" result="docinfo.xml"/>
    </DDX>
    
  3. Map the variable containing the generated PDF, for example, pdfOutput, to the DDX input named generatedPdf.

  4. The Assembler service returns an XML document, such as docinfo.xml, containing the page count in the <NumPages> element:

    code language-none
    <DocInfo xmlns="http://ns.adobe.com/DDX/DocInfo/1.0/">
        ...
        <NumPages>2</NumPages>
        ...
    </DocInfo>
    
  5. Use a Set Value step or an XPath expression to extract the value of <NumPages> for use in the process.

  6. For additional information, refer to the Assembler service documentation and DDX reference.

recommendation-more-help
experience-cloud-kcs-help-kbarticles