Summary of steps
To assemble multiple XDP fragments, perform the following tasks:
- Include project files.
- Create a PDF Assembler client.
- Reference an existing DDX document.
- Reference the XDP documents.
- Set run-time options.
- Assemble the multiple XDP documents.
- Retrieve the assembled XDP document.
Include project files
Include the necessary files in your development project. If you are creating a client application by using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
The following JAR files must be added to your project’s class path:
- adobe-livecycle-client.jar
- adobe-usermanager-client.jar
- adobe-assembler-client.jar
- adobe-utilities.jar (required if AEM Forms is deployed on JBoss)
- jbossall-client.jar (required if AEM Forms is deployed on JBoss)
Create a PDF Assembler client
Before you can programmatically perform an Assembler operation, create an Assembler service client.
Reference an existing DDX document
A DDX document must be referenced to assemble multiple XDP documents. This DDX document must contain XDP result
, XDP source
, and XDPContent
elements.
Reference the XDP documents
To assemble multiple XDP documents, reference all XDP files that are used to assemble the result XDP document. Ensure that the name of the sub form contained in the XDP document that is referenced by the source
attribute is specified in the fragment
attribute. A sub form is defined in Designer. For example, consider the following XML.
<XDPContent insertionPoint="ddx_fragment" source="tuc018_contact.xdp" fragment="subPatientContact" required="false"/>
The sub form named subPatientContact must be in the XDP file named tuc018_contact.xdp.
Set run-time options
You can set run-time options that control the behavior of the Assembler service while it performs a job. For example, you can set an option that instructs the Assembler service to continue processing a job if an error is encountered.
Assemble the multiple XDP documents
To assemble multiple XDP files, call the invokeDDX
operation. The Assembler service returns the assembled XDP document within a collection object.
Retrieve the assembled XDP document
An assembled XDP document is returned within a collection object. Iterate through the collection object and save the XDP document as an XDP file. You can also pass the XDP document to another AEM Forms service, such as Output.
See also
Assemble multiple XDP fragments using the Java API
Assemble multiple XDP fragments using the web service API
Including AEM Forms Java library files
Assemble multiple XDP fragments using the Java API
Assemble multiple XDP fragments by using the Assembler Service API (Java):
-
Include project files.
Include client JAR files, such as adobe-assembler-client.jar, in your Java project’s class path.
-
Create a PDF Assembler client.
- Create a
ServiceClientFactory
object that contains connection properties. - Create an
AssemblerServiceClient
object by using its constructor and passing theServiceClientFactory
object.
- Create a
-
Reference an existing DDX document.
- Create a
java.io.FileInputStream
object that represents the DDX document by using its constructor and passing a string value that specifies the location of the DDX file. - Create a
com.adobe.idp.Document
object by using its constructor and passing thejava.io.FileInputStream
object.
- Create a
-
Reference the XDP documents.
-
Create a
java.util.Map
object that is used to store input XDP documents by using aHashMap
constructor. -
Create a
com.adobe.idp.Document
object and pass thejava.io.FileInputStream
object that contains the input XDP file (repeat this task for each XDP file). -
Add an entry to the
java.util.Map
object by invoking itsput
method and passing the following arguments:- A string value that represents the key name. This value must match the
source
element value specified in the DDX document (repeat this task for each XDP file). - A
com.adobe.idp.Document
object that contains the XDP document that corresponds to thesource
element (repeat this task for each XDP file).
- A string value that represents the key name. This value must match the
-
-
Set the run-time options.
- Create an
AssemblerOptionSpec
object that stores run-time options by using its constructor. - Set run-time options to meet your business requirements by invoking a method that belongs to the
AssemblerOptionSpec
object. For example, to instruct the Assembler service to continue processing a job when an error occurs, invoke theAssemblerOptionSpec
object’ssetFailOnError
method and passfalse
.
- Create an
-
Assemble the multiple XDP documents.
Invoke the
AssemblerServiceClient
object’sinvokeDDX
method and pass the following required values:- A
com.adobe.idp.Document
object that represents the DDX document to use - A
java.util.Map
object that contains the input XDP files - A
com.adobe.livecycle.assembler.client.AssemblerOptionSpec
object that specifies the run-time options, including the default font and the job log level
The
invokeDDX
method returns acom.adobe.livecycle.assembler.client.AssemblerResult
object that contains the assembled XDP document. - A
-
Retrieve the assembled XDP document.
To obtain the assembled XDP document, perform the following actions:
- Invoke the
AssemblerResult
object’sgetDocuments
method. This method returns ajava.util.Map
object. - Iterate through the
java.util.Map
object until you find the resultantcom.adobe.idp.Document
object. - Invoke the
com.adobe.idp.Document
object’scopyToFile
method to extract the assembled XDP document.
- Invoke the
Assemble multiple XDP fragments using the web service API
Assemble multiple XDP fragments by using the Assembler Service API (web service):
-
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition when setting a service reference:
https://localhost:8080/soap/services/AssemblerService?WSDL&lc_version=9.0.1.
NOTE
Replacelocalhost
with the IP address of the server hosting AEM Forms. -
Create a PDF Assembler client.
-
Create an
AssemblerServiceClient
object by using its default constructor. -
Create an
AssemblerServiceClient.Endpoint.Address
object by using theSystem.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service, such ashttps://localhost:8080/soap/services/AssemblerService?blob=mtom
). You do not need to use thelc_version
attribute. This attribute is used when you create a service reference. -
Create a
System.ServiceModel.BasicHttpBinding
object by getting the value of theAssemblerServiceClient.Endpoint.Binding
field. Cast the return value toBasicHttpBinding
. -
Set the
System.ServiceModel.BasicHttpBinding
object’sMessageEncoding
field toWSMessageEncoding.Mtom
. This value ensures that MTOM is used. -
Enable basic HTTP authentication by performing the following tasks:
- Assign the AEM forms user name to the
AssemblerServiceClient.ClientCredentials.UserName.UserName
field. - Assign the corresponding password value to the
AssemblerServiceClient.ClientCredentials.UserName.Password
field. - Assign the
HttpClientCredentialType.Basic
constant value to theBasicHttpBindingSecurity.Transport.ClientCredentialType
field. - Assign the
BasicHttpSecurityMode.TransportCredentialOnly
constant value to theBasicHttpBindingSecurity.Security.Mode
field.
- Assign the AEM forms user name to the
-
-
Reference an existing DDX document.
- Create a
BLOB
object by using its constructor. TheBLOB
object is used to store the DDX document. - Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the DDX document and the mode in which to open the file. - Create a byte array that stores the content of the
System.IO.FileStream
object. You can determine the size of the byte array by getting theSystem.IO.FileStream
object’sLength
property. - Populate the byte array with stream data by invoking the
System.IO.FileStream
object’sRead
method. Pass the byte array, starting position, and stream length to read. - Populate the
BLOB
object by assigning itsMTOM
property with the contents of the byte array.
- Create a
-
Reference the XDP documents.
- For each input XDP file, create a
BLOB
object by using its constructor. TheBLOB
object is used to store the input file. - Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the input file and the mode in which to open the file. - Create a byte array that stores the content of the
System.IO.FileStream
object. You can determine the size of the byte array by getting theSystem.IO.FileStream
object’sLength
property. - Populate the byte array with stream data by invoking the
System.IO.FileStream
object’sRead
method. Pass the byte array, starting position, and stream length to read. - Populate the
BLOB
object by assigning itsMTOM
field with the contents of the byte array. - Create a
MyMapOf_xsd_string_To_xsd_anyType
object. This collection object is used to store input files required to create an assembled XDP document. - For each input file, create a
MyMapOf_xsd_string_To_xsd_anyType_Item
object. - Assign a string value that represents the key name to the
MyMapOf_xsd_string_To_xsd_anyType_Item
object’skey
field. This value must match the value of the element specified in the DDX document. (Perform this task for each input XDP file.) - Assign the
BLOB
object that stores the input file to theMyMapOf_xsd_string_To_xsd_anyType_Item
object’svalue
field. (Perform this task for each input XDP file.) - Add the
MyMapOf_xsd_string_To_xsd_anyType_Item
object to theMyMapOf_xsd_string_To_xsd_anyType
object. Invoke theMyMapOf_xsd_string_To_xsd_anyType
object’sAdd
method and pass theMyMapOf_xsd_string_To_xsd_anyType
object. (Perform this task for each input XDP document.)
- For each input XDP file, create a
-
Set run-time options.
- Create an
AssemblerOptionSpec
object that stores run-time options by using its constructor. - Set run-time options to meet your business requirements by assigning a value to a data member that belongs to the
AssemblerOptionSpec
object. For example, to instruct the Assembler service to continue processing a job when an error occurs, assignfalse
to theAssemblerOptionSpec
object’sfailOnError
data member.
- Create an
-
Assemble the multiple XDP documents.
Invoke the
AssemblerServiceClient
object’sinvokeDDX
method and pass the following values:- A
BLOB
object that represents the DDX document - The
MyMapOf_xsd_string_To_xsd_anyType
object that contains the required files - An
AssemblerOptionSpec
object that specifies run-time options
The
invokeDDX
method returns anAssemblerResult
object that contains the results of the job and any exceptions that occurred. - A
-
Retrieve the assembled XDP document.
To obtain the newly created XDP document, perform the following actions:
- Access the
AssemblerResult
object’sdocuments
field, which is aMap
object that contains the resultant PDF documents. - Iterate through the
Map
object to obtain each resultant document. Then, cast that array member’svalue
to aBLOB
. - Extract the binary data that represents the PDF document by accessing its
BLOB
object’sMTOM
property. This returns an array of bytes that you can write out to an XDP file.
- Access the