Summary of steps

To render a form by value, perform the following steps:

  1. Include project files.
  2. Create a Forms Client API object.
  3. Reference the form design.
  4. Render a form by value.
  5. Write the form data stream to the client web browser.

Include project files

Include necessary files into your development project. If you are creating a client application using Java, then include the necessary JAR files. If you are using web services, then make sure that you include the proxy files.

Create a Forms Client API object

Before you can programmatically import data into a PDF form Client API, you must create a Data Integration service client. When creating a service client, you define connection settings that are required to invoke a service.

Reference the form design

When rendering a form by value, you have to create a com.adobe.idp.Document object that contains the form design to render. You can reference an existing XDP file or you can dynamically create an form design at run-time and populate a com.adobe.idp.Document with that data.

NOTE
This section and the corresponding quick start references an existing XDP file.

Render a form by value

To render a form by value, pass a com.adobe.idp.Document instance that contains the form design to the render method’s inDataDoc parameter (can be any of the FormsServiceClient object’s render methods such as renderPDFForm, (Deprecated) renderHTMLForm, and so on). This parameter value is normally reserved for data that is merged with the form. Likewise, pass an empty string value to the formQuery parameter. Normally this parameter requires a string value that specifies the name of the form design.

NOTE
If you want to display data within the form, the data must be specified within the xfa:datasets element. For information about XFA architecture, go to https://www.pdfa.org/norm-refs/XFA-3_3.pdf.

Write the form data stream to the client web browser

When the Forms service renders a form by value, it returns a form data stream that you must write to the client web browser. When written to the client web browser, the form is visible to the user.

See also

Render a form by value using the Java API

Render a form by value using the web service API

Including AEM Forms Java library files

Setting connection properties

Forms Service API Quick Starts

Passing Documents to the Forms Service

Creating Web Applications that Renders Forms

Render a form by value using the Java API

Render a form by value using the Forms API (Java):

  1. Include project files

    Include client JAR files, such as adobe-forms-client.jar, in your Java project’s class path.

  2. Create a Forms Client API object

    • Create a ServiceClientFactory object that contains connection properties.
    • Create an FormsServiceClient object by using its constructor and passing the ServiceClientFactory object.
  3. Reference the form design

    • Create a java.io.FileInputStream object that represents the form design to render by using its constructor and passing a string value that specifies the location of the XDP file.
    • Create a com.adobe.idp.Document object by using its constructor and passing the java.io.FileInputStream object.
  4. Render a form by value

    Invoke the FormsServiceClient object’s renderPDFForm method and pass the following values:

    • An empty string value. (Normally this parameter requires a string value that specifies the name of the form design.)
    • A com.adobe.idp.Document object that contains the form design. Normally this parameter value is reserved for data that is merged with the form.
    • A PDFFormRenderSpec object that stores run-time options. This is an optional parameter and you can specify null if you do not want to specify run-time options.
    • A URLSpec object that contains URI values that are required by the Forms service.
    • A java.util.HashMap object that stores file attachments. This is an optional parameter and you can specify null if you do not want to attach files to the form.

    The renderPDFForm method returns a FormsResult object that contains a form data stream that can be written to the client web browser.

  5. Write the form data stream to the client web browser

    • Create a com.adobe.idp.Document object by invoking the FormsResult object ‘s getOutputContent method.
    • Get the content type of the com.adobe.idp.Document object by invoking its getContentType method.
    • Set the javax.servlet.http.HttpServletResponse object’s content type by invoking its setContentType method and passing the content type of the com.adobe.idp.Document object.
    • Create a javax.servlet.ServletOutputStream object used to write the form data stream to the client web browser by invoking the javax.servlet.http.HttpServletResponse object’s getOutputStream method.
    • Create a java.io.InputStream object by invoking the com.adobe.idp.Document object’s getInputStream method.
    • Create a byte array and allocate the size of the InputStream object. Invoke the InputStream object’s available method to obtain the size of the InputStream object.
    • Populate the byte array with the form data stream by invoking the InputStream object’s readmethod and passing the byte array as an argument.
    • Invoke the javax.servlet.ServletOutputStream object’s write method to send the form data stream to the client web browser. Pass the byte array to the write method.