Samples and examples in this document are only for AEM Forms on JEE environment.
The Distiller® service converts PostScript®, Encapsulated PostScript (EPS), and PRN files to compact, reliable, and more secure PDF files over a network. The Distiller service is frequently used to convert large volumes of print documents to electronic documents, such as invoices and statements. Converting documents to PDF also allows enterprises to send their customers a paper version and an electronic version of a document.
For more information about the Distiller service, see Services Reference for AEM Forms.
This topic describes how you can use the Distiller Service API (Java and web service) to programmatically convert PostScript (PS), Encapsulated PostScript (EPS), and PRN files to PDF documents.
For more information about the Distiller service, see Services Reference for AEM Forms.
To convert PostScript files to PDF documents, one of the following needs to be installed on the server hosting AEM Forms: Acrobat 9 or Microsoft Visual C++ 2005 redistributable package.
To convert any of the supported types to a PDF document, perform the following steps:
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, make sure you include the proxy files.
Create a Distiller service client
Before you can programmatically perform a Distiller service operation, you must create a Distiller service client. If you are using the Java API, create a DistillerServiceClient
object. If you are using the web service API, create a DistillerServiceService
object.
Retrieve the file to convert
You must retrieve the file that you want to convert. For example, to convert a PS file to a PDF document, you must retrieve the PS file.
Invoke the PDF creation operation
After you create the service client, you can then invoke the PDF creation operation. This operation will need information about the document to be converted, including the path to the target document.
Save the PDF document
You can save the PDF document as a PDF file.
See also
Convert a PostScript file to PDF using the Java API
Converting a PostScript file to PDF using the web service API
Including AEM Forms Java library files
Output Service API Quick Starts
Convert a PostScript file to PDF document by using the Distiller Service API (Java):
Include project files.
Include client JAR files, such as adobe-distiller-client.jar, in your Java project’s class path.
Create a Distiller service client.
ServiceClientFactory
object that contains connection properties.DistillerServiceClient
object by using its constructor and passing the ServiceClientFactory
object.Retrieve the file to convert.
java.io.FileInputStream
object that represents the file to convert by using its constructor and passing a string value that specifies the location of the file.com.adobe.idp.Document
object by using its constructor and passing the java.io.FileInputStream
object.Invoke the PDF creation operation.
Invoke the DistillerServiceClient
object’s createPDF
method and pass the following values:
com.adobe.idp.Document
object that represents the PS, EPS, or PRN file to be convertedjava.lang.String
object that contains the name of the file to be convertedjava.lang.String
object that contains the name of the Adobe PDF settings to be usedjava.lang.String
object that contains the name of the security settings to be usedcom.adobe.idp.Document
object that contains settings to be applied while generating the PDF documentcom.adobe.idp.Document
object that contains metadata information to be applied to the PDF documentThe createPDF
method returns a CreatePDFResult
object that contains the new PDF document and a log file that may be generated. The log file typically contains error or warning messages that are generated by the conversion request.
Save the PDF document.
To obtain the newly created PDF document, perform the following actions:
CreatePDFResult
object’s getCreatedDocument
method. This returns a com.adobe.idp.Document
object.com.adobe.idp.Document
object’s copyToFile
method to extract the PDF document.Similarly, to obtain the log document, perform the following actions.
CreatePDFResult
object’s getLogDocument
method. This returns a com.adobe.idp.Document
object.com.adobe.idp.Document
object’s copyToFile
method to extract the log document.See also
Quick Start (SOAP mode): Converting a PostScript file to a PDF document using the Java API
Including AEM Forms Java library files
Convert a PostScript file to PDF document by using the Distiller 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/DistillerService?WSDL&lc_version=9.0.1
.
Replace localhost
with the IP address of the server hosting AEM Forms.
Create a Distiller service client.
Create a DistillerServiceClient
object by using its default constructor.
Create a DistillerServiceClient.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/DistillerService?blob=mtom
.) You do not need to use the lc_version
attribute. This attribute is used when you create a service reference. However, specify ?blob=mtom
to use MTOM.
Create a System.ServiceModel.BasicHttpBinding
object by getting the value of the DistillerServiceClient.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:
DistillerServiceClient.ClientCredentials.UserName.UserName
.DistillerServiceClient.ClientCredentials.UserName.Password
.HttpClientCredentialType.Basic
to the field BasicHttpBindingSecurity.Transport.ClientCredentialType
.BasicHttpSecurityMode.TransportCredentialOnly
to the field BasicHttpBindingSecurity.Security.Mode
.Retrieve the file to convert.
BLOB
object by using its constructor. This BLOB
object is used to store the file to convert to a PDF document.System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location and the mode to open the file in.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.Invoke the PDF creation operation.
Invoke the DistillerServiceService
object’s CreatePDF2
method and pass the following required values:
BLOB
object that represents the PS file to convertStandard
)No Securit
y)BLOB
object that contains settings to be applied while generating the PDF documentBLOB
object that contains metadata information to be applied to the PDF documentBLOB
output parameter used to store the PDF documentBLOB
output parameter used to store the logSave the PDF document.
System.IO.FileStream
object by invoking its constructor. Pass a string value that represents the file location of the signed PDF document and the mode in which to open the file.BLOB
object that was returned by the CreatePDF2
method (the output parameter). Populate the byte array by getting the value of the BLOB
object’s MTOM
data member.System.IO.BinaryWriter
object by invoking its constructor and passing the System.IO.FileStream
object.System.IO.BinaryWriter
object’s Write
method and passing the byte array.See also
Invoking AEM Forms using SwaRef