Render a form at the client using the Java API

Render a form at the client by 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. Set client rendering run-time options

    • Create a PDFFormRenderSpec object by using its constructor.
    • Set the RenderAtClient run-time option by invoking the PDFFormRenderSpec object’s setRenderAtClient method and passing the enum value RenderAtClient.Yes.
  4. Render a form at the client

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

    • A string value that specifies the form design name, including the file name extension. If you reference a form design that is part of a AEM Forms application, ensure that you specify the complete path, such as Applications/FormsApplication/1.0/FormsFolder/Loan.xdp.
    • A com.adobe.idp.Document object that contains data to merge with the form. If you do not want to merge data, pass an empty com.adobe.idp.Document object.
    • A PDFFormRenderSpec object that stores run-time options required to render a form at the client.
    • A URLSpec object that contains URI values that are required by the Forms service to render a form.
    • 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 must 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 populate it with the form data stream by invoking the InputStream object’s read method 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.

Render a form at the client using the web service API

Render a form at the client by using the Forms API (web service):

  1. Include project files

    • Create Java proxy classes that consume the Forms service WSDL.
    • Include the Java proxy classes into your class path.
  2. Create a Forms Client API object

    Create a FormsService object and set authentication values.

  3. Set client rendering run-time options

    • Create a PDFFormRenderSpec object by using its constructor.
    • Set the RenderAtClient run-time option by invoking the PDFFormRenderSpec object’s setRenderAtClient method and passing the string value RenderAtClient.Yes.
  4. Render a form at the client

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

    • A string value that specifies the form design name, including the file name extension. If you reference a form design that is part of a Forms application, ensure that you specify the complete path, such as Applications/FormsApplication/1.0/FormsFolder/Loan.xdp.
    • A BLOB object that contains data to merge with the form. If you do not want to merge data, pass null. (See Prepopulating Forms with Flowable Layouts.)
    • A PDFFormRenderSpec object that stores run-time options required to render a form at the client.
    • 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.
    • An empty com.adobe.idp.services.holders.BLOBHolder object that is populated by the method. This parameter is used to store the rendered PDF form.
    • An empty javax.xml.rpc.holders.LongHolder object that is populated by the method. (This argument will store the number of pages in the form).
    • An empty javax.xml.rpc.holders.StringHolder object that is populated by the method. (This argument will store the locale value).
    • An empty com.adobe.idp.services.holders.FormsResultHolder object that will contain the results of this operation.

    The renderPDFForm method populates the com.adobe.idp.services.holders.FormsResultHolder object that is passed as the last argument value with a form data stream that must be written to the client web browser.

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

    • Create a FormResult object by getting the value of the com.adobe.idp.services.holders.FormsResultHolder object’s value data member.
    • Create a BLOB object that contains form data by invoking the FormsResult object’s getOutputContent method.
    • Get the content type of the BLOB 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 BLOB 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 byte array and populate it by invoking the BLOB object’s getBinaryData method. This task assigns the content of the FormsResult object to the byte array.
    • Invoke the javax.servlet.http.HttpServletResponse object’s write method to send the form data stream to the client web browser. Pass the byte array to the write method.

Experience Manager


Espressos & Experience Manager: AEM Forms

Espressos & Experience Manager

Thursday, Mar 6, 7:00 PM UTC

Join Adobe's AEM product team as they highlight AEM Forms' latest innovations, including: the new Gen AI Assistant, Unified Composition with AEM Sites, and new ways to deploy forms through conversations.

Register

Put the Customer at the Center and Build Relationships That Last a Lifetime

Online | Strategy Keynote | General Audience

First impressions last a lifetime. Great first impressions feel personal, connected, and relevant right from the start. From the first...

Wed, Mar 19, 2:30 PM PDT (9:30 PM UTC)

Register

Driving Marketing Agility and Scale: Transforming your Content Supply Chain with AI

Online | Strategy Keynote | General Audience

Marketers everywhere are feeling the pressure to deliver impactful campaigns faster and at greater scale. This Strategy Keynote explores...

Tue, Mar 18, 2:30 PM PDT (9:30 PM UTC)

Register

Connect with Experience League at Summit!

Get front-row access to top sessions, hands-on activities, and networking—wherever you are!

Learn more