Creating pre-filled and interactive PDF forms

This Quick Start describes how to use the Forms to render an interactive PDF form with pre-filled data. For more information about the Forms service, see Services Reference for AEM forms.

Using the Forms service, a form design can be merged with XML data, and rendered as a pre-filled, interactive PDF form. For example, users log in to a web-based system and open an interactive purchase form using Adobe Acrobat version 8.0 or later. The form is pre-filled with shipping, contact, and purchase order information. Users fill in the remaining purchase order details and save the PDF form.

An application, named poPDFApp , implements this service for the organization. The form design, named purchaseOrder.xdp , is available as part of the application. An XML file, which contains the shipping, contact, and purchase order information, is merged with the form design to render the interactive PDF form. The resulting PDF form is saved to the network location specified by the user, such as \\user1\POForm.pdf . Users retrieve the PDF form from the network location, fill, save, and send it electronically.

The following assets are in the poPDFApp application:

  • A form design named purchaseOrder.xdp that is used to render the PDF form. Form designs are created using Designer . (See Designer Help .)

  • A process, named createPOForm, that includes the following items:

    • An input document variable, named poShipXML , that stores the XML data with shipping, contact, and purchase order information.

    • An input string variable, named savePOLocation , that stores the network location to save the purchase order form.

    • An output document variable, named ouputPDF , that stores the interactive PDF form.

    • A renderPDFForm operation (Forms service) that merges a form design with an XML file and renders an interactive PDF form. The resulting output is a document value that represents the PDF document.

  • A Write Document operation (File Utilities service) that saves the document value to the file system.

The process diagram for the createPOForm process looks like the following illustration:

generatePrintedOutput and sendtoPrinter operations.

The following XML document provides the shipping information to pre-fill the rendered PDF form:

<?xml version="1.0" encoding="UTF-8"?> 
<poform1> 
    <txtPONum>8745236985</txtPONum> 
    <dtmDate>2004-02-08</dtmDate> 
    <txtShipCompanyName>Fin@nce Incorporated</txtOrderedByCompanyName> 
    <txtShipAddress>123, Any Blvd.</txtOrderedByAddress> 
    <txtShipCity>Any City</txtOrderedByCity> 
    <txtShipStateProv>Any State</txtOrderedByStateProv> 
    <txtShipZipCode>12345</txtOrderedByZipCode> 
    <txtShipCountry>Any Country</txtOrderedByCountry> 
    <txtShipPhone>(123) 456-7890</txtOrderedByPhone> 
    <txtShipFax>(123) 456-7899</txtOrderedByFax> 
    <txtShipContactName>Akira Tanaka</txtOrderedByContactName> 
</poform1>

Configuration

For the renderPDFOrm operation, the following properties are configured to generate an interactive PDF form:

Input

  • Form: A literal value of poPDFApp > createPOForm/1.0 > purchaseOrder.xdp is selected to specify the form design. The Select Asset dialog box is used to select a literal value.

  • Input Data: The poShipXML variable that contains the contents from the poShipInfo.xml file.

PDF Options

  • Acrobat Version : The Acrobat and Reader 8.0 and above item is selected from the list. The item specifies to generate a PDF document that requires Acrobat or Adobe Reader 8.0 or later to open it.

Output

  • Rendered Form: The outputPDF variable that stores the PDF form.

    For the Write Document operation, the following properties are configured to save the interactive PDF form to a network location:

Input

  • Pathname Pattern: The savePOLocation variable that specifies the name of the file.

  • Document: The outputPDF variable that specifies the content to save as a file.

Other considerations

Instead of writing the PDF form to a network location, consider sending the PDF form (as a byte stream) to a Java servlet. The Java servlet can display the form to a web page. (See Creating Web Applications that Renders Forms in Programming with AEM forms .)

Consider using the processFormSubmission operation in a separate process to handle the submission of data from a rendered PDF form.

Use the Acrobat Reader DC extensions service to apply usage rights to the PDF form when users use Adobe Reader to fill the form. (See Apply Usage Rights operation .)

// Ethnio survey code removed