Samples and examples in this document are only for AEM Forms on JEE environment.
Web-based applications that enable users to fill interactive forms require the data to be submitted back to the server. Using the Forms service, you can retrieve the form data that the user entered into an interactive form. Then you can pass the form data to another AEM Forms service operation and create a PDF document using the data.
Before you read this content, it is recommended that you have a solid understanding of handling submitted forms. Concepts such as the relationship between a form design and submitted XML data are covered in Handling submitted Forms.
Consider the following workflow that involves three AEM Forms services:
The following diagram provides a visual representation of this workflow.
After the user submits the form from the client web browser, the non-interactive PDF document is stored in Content Services (deprecated). The following illustration shows a PDF document stored in Content Services (deprecated).
To create a non-interactive PDF document with submitted XML data and store in the PDF document in Content Services (deprecated), perform the following tasks:
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 Forms, Output, and Document Management objects
Before you can programmatically perform a Forms service API operation, create a Forms Client API object. Likewise, because this workflow invokes the Output and Document Management services, create both an Output Client API object and a Document Management Client API object.
Retrieve form data using the Forms service
Retrieve form data that was submitted to the Forms service. You can process submitted data to meet your business requirements. For example, you can store form data in an enterprise database. However, to create a non-interactive PDF document, the form data is passed to the Output service.
Create a non-interactive PDF document using the Output service.
Use the Output service to create a non-interactive PDF document that is based on a form design and XML form data. In the workflow, the form data is retrieved from the Forms service.
Store the PDF form in Content Services (deprecated) using the Document Management service
Use the Document Management service API to store a PDF document in Content Services (deprecated).
See also
Including AEM Forms Java library files
Forms Service API Quick Starts
Create a PDF document with submitted XML data by using the Forms, Output, and Document Management API (Java):
Include project files
Include client JAR files, such as adobe-forms-client.jar, adobe-output-client.jar, and adobe-contentservices-client.jar in your Java project’s class path.
Create Forms, Output, and Document Management objects
ServiceClientFactory
object that contains connection properties.FormsServiceClient
object by using its constructor and passing the ServiceClientFactory
object.OutputClient
object by using its constructor and passing the ServiceClientFactory
object.DocumentManagementServiceClientImpl
object by using its constructor and passing the ServiceClientFactory
object.Retrieve form data using the Forms service
Invoke the FormsServiceClient
object’s processFormSubmission
method and pass the following values:
com.adobe.idp.Document
object that contains the form data.CONTENT_TYPE
environment variable. For example, to handle XML data, specify the following string value for this parameter: CONTENT_TYPE=text/xml
.HTTP_USER_AGENT
header value, such as Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
.RenderOptionsSpec
object that stores run-time options.The processFormSubmission
method returns a FormsResult
object containing the results of the form submission.
Determine whether the Forms service is finished processing the form data by invoking the FormsResult
object’s getAction
method. If this method returns the value 0
, the data is ready to be processed.
Retrieve form data by creating a com.adobe.idp.Document
object by invoking the FormsResult
object’s getOutputContent
method. (This object contains form data that can be sent to the Output service.)
Create a java.io.InputStream
object by invoking the java.io.DataInputStream
constructor and passing the com.adobe.idp.Document
object.
Create an org.w3c.dom.DocumentBuilderFactory
object by calling the static org.w3c.dom.DocumentBuilderFactory
object’s newInstance
method.
Create an org.w3c.dom.DocumentBuilder
object by invoking the org.w3c.dom.DocumentBuilderFactory
object’s newDocumentBuilder
method.
Create an org.w3c.dom.Document
object by invoking the org.w3c.dom.DocumentBuilder
object’s parse
method and passing the java.io.InputStream
object.
Retrieve the value of each node within the XML document. One way to accomplish this task is to create a custom method that accepts two parameters: the org.w3c.dom.Document
object and the name of the node whose value you want to retrieve. This method returns a string value representing the value of the node. In the code example that follows this process, this custom method is called getNodeText
. The body of this method is shown.
Create a non-interactive PDF document using the Output service.
Create a PDF document by invoking the OutputClient
object’s generatePDFOutput
method and passing the following values:
TransformationFormat
enum value. To generate a PDF document, specify TransformationFormat.PDF
.PDFOutputOptionsSpec
object that contains PDF run-time options.RenderOptionsSpec
object that contains rendering run-time options.com.adobe.idp.Document
object that contains the XML data source that contains data to merge with the form design. Ensure that this object was returned by the FormsResult
object’s getOutputContent
method.generatePDFOutput
method returns an OutputResult
object that contains the results of the operation.OutputResult
object’s getGeneratedDoc
method. This method returns a com.adobe.idp.Document
instance that represents the non-interactive PDF document.Store the PDF form in Content Services (deprecated)using the Document Management service
Add the content by invoking the DocumentManagementServiceClientImpl
object’s storeContent
method and passing the following values:
SpacesStore
. This value is a mandatory parameter./Company Home/Test Directory
). This value is a mandatory parameter.MortgageForm.pdf
). This value is a mandatory parameter.{https://www.alfresco.org/model/content/1.0}content
. This value is a mandatory parameter.com.adobe.idp.Document
object that represents the content. This value is a mandatory parameter.UTF-8
). This value is a mandatory parameter.UpdateVersionType
enumeration value that specifies how to handle version information (for example, UpdateVersionType.INCREMENT_MAJOR_VERSION
to increment the content version. ) This value is a mandatory parameter.java.util.List
instance that specifies aspects related to the content. This value is an optional parameter and you can specify null
.java.util.Map
object that stores content attributes.The storeContent
method returns a CRCResult
object that describes the content. Using a CRCResult
object, you can, for example, obtain the content’s unique identifier value. To perform this task, invoke the CRCResult
object’s getNodeUuid
method.
See also
Including AEM Forms Java library files