Disassemble a PDF document 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: http://localhost:8080/soap/services/AssemblerService?WSDL&lc_version=9.0.1
.
Replace localhost
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 the System.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 the lc_version
attribute. This attribute is used when you create a service reference.
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the AssemblerServiceClient.Endpoint.Binding
field. Cast the return value to BasicHttpBinding
.
Set the System.ServiceModel.BasicHttpBinding
object’s MessageEncoding
field to WSMessageEncoding.Mtom
. This value ensures that MTOM is used.
Enable basic HTTP authentication by performing the following tasks:
AssemblerServiceClient.ClientCredentials.UserName.UserName
.AssemblerServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Reference an existing DDX document.
BLOB
object by using its constructor. The BLOB
object is used to store the DDX document.System.IO.FileStream
object by invoking its constructor. Pass a string value that represents the file location of the DDX document and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning its MTOM
property with the contents of the byte array.Reference a PDF document to disassemble.
BLOB
object by using its constructor. The BLOB
object is used to store the input PDF document. This BLOB
object is passed to the invokeOneDocument
as an argument.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the input PDF document and the mode in which to open the file.System.IO.FileStream
object. You can determine the size of the byte array by getting the System.IO.FileStream
object’s Length
property.System.IO.FileStream
object’s Read
method and passing the byte array, the starting position, and the stream length to read.BLOB
object by assigning its MTOM
field the contents of the byte array.MyMapOf_xsd_string_To_xsd_anyType
object. This collection object is used to store the PDF to disassemble.MyMapOf_xsd_string_To_xsd_anyType_Item
object.MyMapOf_xsd_string_To_xsd_anyType_Item
object’s key
field. This value must match the value of the PDF source element specified in the DDX document.BLOB
object that stores the PDF document to the MyMapOf_xsd_string_To_xsd_anyType_Item
object’s value
field.MyMapOf_xsd_string_To_xsd_anyType_Item
object to the MyMapOf_xsd_string_To_xsd_anyType
object. Invoke the MyMapOf_xsd_string_To_xsd_anyType
object’ Add
method and pass the MyMapOf_xsd_string_To_xsd_anyType
object.Set run-time options.
AssemblerOptionSpec
object that stores run-time options by using its constructor.AssemblerOptionSpec
object. For example, to instruct the Assembler service to continue processing a job when an error occurs, assign false
to the AssemblerOptionSpec
object’s failOnError
field.Disassemble the PDF document.
Invoke the AssemblerServiceClient
object’s invokeDDX
method and pass the following values:
BLOB
object that represents the DDX document that disassembles the PDF documentMyMapOf_xsd_string_To_xsd_anyType
object that contains the PDF document to disassembleAssemblerOptionSpec
object that specifies run-time optionsThe invokeDDX
method returns an AssemblerResult
object that contains the job results and any exceptions that occurred.
Save the disassembled PDF documents.
To obtain the newly created PDF documents, perform the following actions:
AssemblerResult
object’s documents
field, which is a Map
object that contains the disassembled PDF documents.Map
object to obtain each resultant document. Then, cast that array member’s value
to a BLOB
.BLOB
object’s MTOM
property. This returns an array of bytes that you can write out to a PDF file.See also
Programmatically Disassembling PDF Documents