Summary of steps
To assemble a PDF document that contains a unique page identifier (Bates numbering), perform the following tasks:
- Include project files.
- Create a PDF Assembler client.
- Reference an existing DDX document.
- Reference input PDF documents.
- Set the initial Bates number value.
- Assemble the input PDF documents.
- Extract the results.
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)
If AEM Forms is deployed on a supported J2EE application server other than JBoss, you must replace the adobe-utilities.jar and jbossall-client.jar files with JAR files that are specific to the J2EE application server on which AEM Forms is deployed. For information about the location of all AEM Forms JAR files, see Including AEM Forms Java library files.
Create a PDF Assembler client
Before you can programmatically perform an Assembler operation, you must create an Assembler service client.
Reference an existing DDX document
A DDX document must be referenced to assemble a PDF document. For example, consider the DDX document that was introduced in this section. To assemble a PDF document that contains unique page identifiers, the DDX document must contain the BatesNumber
element.
Reference input PDF documents
Input PDF documents must be referenced to assemble a PDF document. For example, the map.pdf and directions.pdf documents must be referenced to assemble these PDF documents into a single PDF document.
Set the initial Bates number value
You can set the initial Bates number value to meet your business requirements. For example, assume that it is a requirement to set the initial value to 000100. If you do not set the initial value, the value of the first page is 000000.
Assemble the input PDF documents
After you create the Assembler service client, reference the DDX document that contains BatesNumber
element information, reference an input PDF document, and set run-time options, you can invoke the invokeDDX
operation that results in the Assembler service assembling a PDF document that contains unique page identifiers.
Extract the results
The Assembler service returns a collection object that contains the job results. You can extract the resultant PDF document and any exceptions that are thrown. In this situation, an encrypted PDF document is located within the collection object.
invokeDDX
operation. This operation is used when passing two or more input PDF documents to the Assembler service. However if you pass only one input PDF document to the Assembler service, you should invoke the invokeOneDocument
operation. For information about using this operation, see Assembling Encrypted PDF Documents.Assemble documents with Bates numbering using the Java API
Assemble a PDF document that uses unique page identifiers (Bates numbering) 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 input PDF documents.
-
Create a
java.util.Map
object used to store input PDF documents by using aHashMap
constructor. -
For each input PDF document, create a
java.io.FileInputStream
object by using its constructor and passing the location of the input PDF document. In this situation, pass the location of an unsecured PDF document. -
For each input PDF document, create a
com.adobe.idp.Document
object and pass thejava.io.FileInputStream
object that contains the PDF document. -
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 value of the PDF source element specified in the DDX document. For example, the name of the PDF source file specified in the DDX document that is introduced in this section is Loan.pdf.
- A
com.adobe.idp.Document
object that contains the unsecured PDF document.
-
-
Set the initial Bates number value.
- Create an
AssemblerOptionSpec
object that stores run-time options by using its constructor. - Set the initial Bates number by invoking the
AssemblerOptionSpec
object’ssetFirstBatesNumber
and passing a numeric value that specifies the initial value.
- Create an
-
Assemble the input PDF documents.
Invoke the
AssemblerServiceClient
object’sinvokeDDX
method and pass the following required values:- A
com.adobe.idp.Document
object that represents the DDX document. - A
java.util.Map
object that contains the input unsecured PDF file. - A
com.adobe.livecycle.assembler.client.AssemblerOptionSpec
object that specifies the run-time options, including default font and job log level.
The
invokeDDX
method returns acom.adobe.livecycle.assembler.client.AssemblerResult
object that contains a password-encrypted PDF document. - A
-
Extract the results.
To obtain the newly created PDF document, perform the following actions:
- Invoke the
AssemblerResult
object’sgetDocuments
method. This action returns ajava.util.Map
object. - Iterate through the
java.util.Map
object until you find thecom.adobe.idp.Document
object. - Invoke the
com.adobe.idp.Document
object’scopyToFile
method to extract the PDF document.
- Invoke the
Assemble documents with Bates numbering using the web service API
Assemble a PDF document that uses unique page identifiers (Bates numbering) 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:
http://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 (for example,http://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 field
AssemblerServiceClient.ClientCredentials.UserName.UserName
. - Assign the corresponding password value to the field
AssemblerServiceClient.ClientCredentials.UserName.Password
. - Assign the constant value
HttpClientCredentialType.Basic
to the fieldBasicHttpBindingSecurity.Transport.ClientCredentialType
. - Assign the constant value
BasicHttpSecurityMode.TransportCredentialOnly
to the fieldBasicHttpBindingSecurity.Security.Mode
.
- Assign the AEM forms user name to the field
-
-
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 to open the file in. - 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, the starting position, and the stream length to read. - Populate the
BLOB
object by assigning itsMTOM
field with the contents of the byte array.
- Create a
-
Reference input PDF documents.
- For each input PDF document, create a
BLOB
object by using its constructor. TheBLOB
object is used to store the input PDF document. - Create a
System.IO.FileStream
object by invoking its constructor. Pass a string value that represents the file location of the input PDF 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, the starting position, and the stream length to read. - Populate the
BLOB
object by assigning itsMTOM
property with the contents of the byte array. - Create a
MyMapOf_xsd_string_To_xsd_anyType
object. This collection object is used to store the input PDF documents. - For each input PDF document, create a
MyMapOf_xsd_string_To_xsd_anyType_Item
object. For example, if two input PDF documents are used, create twoMyMapOf_xsd_string_To_xsd_anyType_Item
objects. - 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 PDF source element specified in the DDX document. (Perform this task for each input PDF document.) - Assign the
BLOB
object that stores the PDF document to theMyMapOf_xsd_string_To_xsd_anyType_Item
object’svalue
field. (Perform this task for each input PDF document.) - 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 PDF document.)
- For each input PDF document, create a
-
Set the initial Bates number value.
- Create an
AssemblerOptionSpec
object that stores run-time options by using its constructor. - Set the initial Bates number by assigning a numeric value to the
firstBatesNumber
data member that belongs to theAssemblerOptionSpec
object.
- Create an
-
Assemble the input PDF documents.
Invoke the
AssemblerServiceClient
object’sinvoke
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 input PDF documents. Its keys must match the names of the PDF source files, and its values must be theBLOB
objects that corresponds to those files. - An
AssemblerOptionSpec
object that specifies run-time options.
The
invoke
method returns anAssemblerResult
object that contains the results of the job and any exceptions that occurred. - A
-
Extract the results.
To obtain the newly created PDF document, perform the following actions:
- Access the
AssemblerResult
object’sdocuments
field, which is aMap
object that contains the result PDF documents. - Iterate through the
Map
object until you find the key that matches the name of the 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 a PDF file.
- Access the
See also