Rendering Forms at the Client rendering-forms-at-the-client
Samples and examples in this document are only for AEM Forms on JEE environment.
Rendering Forms at the Client rendering-forms-at-the-client-inner
You can optimize the delivery of PDF content and improve the Forms service’s ability to handle network load by using the client-side rendering capability of Acrobat or Adobe Reader. This process is known as rendering a form at the client. To render a form at the client, the client device (typically a web browser) must use Acrobat 7.0 or Adobe Reader 7.0 or later.
Changes to a form resulting from server-side script execution is not reflected in a form that is rendered at the client unless the root subform contains the restoreState attribute that is set to auto. For more information about this attribute, see Forms Designer.
Summary of steps summary-of-steps
To render a form at the client, perform the following tasks:
- Include project files.
- Create a Forms Client API object.
- Set client rendering run-time options.
- Render a form at the client.
- Write the form to the client web browser.
Include project files
Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
Create a Forms Client API object
Before you can programmatically perform a Forms service Client API operation, you must create a Forms service client. If you are using the Java API, create a FormsServiceClient object. If you are using the Forms web service API, create a FormsService object.
Set client rendering run-time options
Set the client rendering run-time option to render a form at the client by setting the RenderAtClient run-time option to true. This results in the form being delivered to the client device where it is rendered. If RenderAtClient is auto (the default value), the form design determines whether the form is rendered at the client. The form design must be a form design with a flowable layouyt.
An optional run-time option that you may set is the SeedPDF option. The SeedPDF option combines the PDF container (seed PDF document) with the form design and the XML data. Both the form design and the XML data are delivered to Acrobat or Adobe Reader, where the form is rendered. The SeedPDF option can be used when the client computer does not have fonts that are used in the form, such as when an end user is not licensed to use a font that the form owner is licensed to use.
You can use Designer to create a simple dynamic PDF file for use as a seed PDF file. The following steps are required to perform this task:
- Determine whether you need to embed any fonts within the seed PDF file. The seed PDF file must contain additional fonts required by the form being rendered. When embedding fonts into the seed PDF file, ensure that you are not violating any font licensing agreements. In Designer, you can determine whether you can legally embed fonts. Upon saving, if there are fonts you cannot embed into the form, Designer displays a message listing the fonts you cannot embed. This message is not displayed in Designer for static PDF documents.
- If you are creating the seed PDF file in Designer, it is recommended that, at a minimum, you add a text field that contains a message. The message should be directed at users of earlier versions of Adobe Reader stating that they need Acrobat 7.0 or later or Adobe Reader 7.0 or later to view the document.
- Save the seed PDF file as a dynamic PDF file with the PDF file name extension.
Render a form at the client
To render a form at the client, you must ensure that the client rendering run-time options are included in your application logic to render a form.
Write the form data stream to the client web browser
The Forms service creates a form data stream that you must write to the client web browser. When written to the client web browser, the form is rendered by Acrobat 7.0 or Adobe Reader 7.0 or later, and is visible to the user.
See also
Render a form at the client using the Java API
Render a form at the client using the web service API
Including AEM Forms Java library files
Forms Service API Quick Starts
Render a form at the client using the Java API render-a-form-at-the-client-using-the-java-api
Render a form at the client by using the Forms API (Java):
-
Include project files
Include client JAR files, such as adobe-forms-client.jar, in your Java project’s class path.
-
Create a Forms Client API object
- Create a
ServiceClientFactoryobject that contains connection properties. - Create an
FormsServiceClientobject by using its constructor and passing theServiceClientFactoryobject.
- Create a
-
Set client rendering run-time options
- Create a
PDFFormRenderSpecobject by using its constructor. - Set the
RenderAtClientrun-time option by invoking thePDFFormRenderSpecobject’ssetRenderAtClientmethod and passing the enum valueRenderAtClient.Yes.
- Create a
-
Render a form at the client
Invoke the
FormsServiceClientobject’srenderPDFFormmethod 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.Documentobject that contains data to merge with the form. If you do not want to merge data, pass an emptycom.adobe.idp.Documentobject. - A
PDFFormRenderSpecobject that stores run-time options required to render a form at the client. - A
URLSpecobject that contains URI values that are required by the Forms service to render a form. - A
java.util.HashMapobject that stores file attachments. This is an optional parameter and you can specifynullif you do not want to attach files to the form.
The
renderPDFFormmethod returns aFormsResultobject that contains a form data stream that must be written to the client web browser. - 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
-
Write the form data stream to the client web browser
- Create a
com.adobe.idp.Documentobject by invoking theFormsResultobject ‘sgetOutputContentmethod. - Get the content type of the
com.adobe.idp.Documentobject by invoking itsgetContentTypemethod. - Set the
javax.servlet.http.HttpServletResponseobject’s content type by invoking itssetContentTypemethod and passing the content type of thecom.adobe.idp.Documentobject. - Create a
javax.servlet.ServletOutputStreamobject used to write the form data stream to the client web browser by invoking thejavax.servlet.http.HttpServletResponseobject’sgetOutputStreammethod. - Create a
java.io.InputStreamobject by invoking thecom.adobe.idp.Documentobject’sgetInputStreammethod. - Create a byte array and populate it with the form data stream by invoking the
InputStreamobject’sreadmethod and passing the byte array as an argument. - Invoke the
javax.servlet.ServletOutputStreamobject’swritemethod to send the form data stream to the client web browser. Pass the byte array to thewritemethod.
- Create a
See also
Quick Start (SOAP mode): Rendering a form at the client using the Java API
Render a form at the client using the web service API render-a-form-at-the-client-using-the-web-service-api
Render a form at the client by using the Forms API (web service):
-
Include project files
- Create Java proxy classes that consume the Forms service WSDL.
- Include the Java proxy classes into your class path.
-
Create a Forms Client API object
Create a
FormsServiceobject and set authentication values. -
Set client rendering run-time options
- Create a
PDFFormRenderSpecobject by using its constructor. - Set the
RenderAtClientrun-time option by invoking thePDFFormRenderSpecobject’ssetRenderAtClientmethod and passing the string valueRenderAtClient.Yes.
- Create a
-
Render a form at the client
Invoke the
FormsServiceobject’srenderPDFFormmethod 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
BLOBobject that contains data to merge with the form. If you do not want to merge data, passnull. (See Prepopulating Forms with Flowable Layouts.) - A
PDFFormRenderSpecobject that stores run-time options required to render a form at the client. - A
URLSpecobject that contains URI values that are required by the Forms service. - A
java.util.HashMapobject that stores file attachments. This is an optional parameter and you can specifynullif you do not want to attach files to the form. - An empty
com.adobe.idp.services.holders.BLOBHolderobject that is populated by the method. This parameter is used to store the rendered PDF form. - An empty
javax.xml.rpc.holders.LongHolderobject that is populated by the method. (This argument will store the number of pages in the form). - An empty
javax.xml.rpc.holders.StringHolderobject that is populated by the method. (This argument will store the locale value). - An empty
com.adobe.idp.services.holders.FormsResultHolderobject that will contain the results of this operation.
The
renderPDFFormmethod populates thecom.adobe.idp.services.holders.FormsResultHolderobject that is passed as the last argument value with a form data stream that must be written to the client web browser. - 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
-
Write the form data stream to the client web browser
- Create a
FormResultobject by getting the value of thecom.adobe.idp.services.holders.FormsResultHolderobject’svaluedata member. - Create a
BLOBobject that contains form data by invoking theFormsResultobject’sgetOutputContentmethod. - Get the content type of the
BLOBobject by invoking itsgetContentTypemethod. - Set the
javax.servlet.http.HttpServletResponseobject’s content type by invoking itssetContentTypemethod and passing the content type of theBLOBobject. - Create a
javax.servlet.ServletOutputStreamobject used to write the form data stream to the client web browser by invoking thejavax.servlet.http.HttpServletResponseobject’sgetOutputStreammethod. - Create a byte array and populate it by invoking the
BLOBobject’sgetBinaryDatamethod. This task assigns the content of theFormsResultobject to the byte array. - Invoke the
javax.servlet.http.HttpServletResponseobject’swritemethod to send the form data stream to the client web browser. Pass the byte array to thewritemethod.
- Create a
See also
Invoking AEM Forms using Base64 encoding