Converting Postscript to PDF Documents converting-postscript-to-pdf-documents
Samples and examples in this document are only for AEM Forms on JEE environment.
About the Distiller Service about-the-distiller-service
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.
Converting PostScript to PDF documents converting-postscript-to-pdf-documents-inner
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.
Summary of steps summary-of-steps
To convert any of the supported types to a PDF document, perform the following steps:
- Include project files.
- Create a Distiller service client.
- Retrieve the file to convert.
- Invoke the PDF creation operation.
- Save the PDF 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, 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
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
Convert a PostScript file to PDF using the Java API convert-a-postscript-file-to-pdf-using-the-java-api
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.
- Create a
ServiceClientFactoryobject that contains connection properties. - Create an
DistillerServiceClientobject by using its constructor and passing theServiceClientFactoryobject.
- Create a
-
Retrieve the file to convert.
- Create a
java.io.FileInputStreamobject that represents the file to convert by using its constructor and passing a string value that specifies the location of the file. - Create a
com.adobe.idp.Documentobject by using its constructor and passing thejava.io.FileInputStreamobject.
- Create a
-
Invoke the PDF creation operation.
Invoke the
DistillerServiceClientobject’screatePDFmethod and pass the following values:- The
com.adobe.idp.Documentobject that represents the PS, EPS, or PRN file to be converted - A
java.lang.Stringobject that contains the name of the file to be converted - A
java.lang.Stringobject that contains the name of the Adobe PDF settings to be used - A
java.lang.Stringobject that contains the name of the security settings to be used - An optional
com.adobe.idp.Documentobject that contains settings to be applied while generating the PDF document - An optional
com.adobe.idp.Documentobject that contains metadata information to be applied to the PDF document
The
createPDFmethod returns aCreatePDFResultobject 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. - The
-
Save the PDF document.
To obtain the newly created PDF document, perform the following actions:
- Invoke the
CreatePDFResultobject’sgetCreatedDocumentmethod. This returns acom.adobe.idp.Documentobject. - Invoke the
com.adobe.idp.Documentobject’scopyToFilemethod to extract the PDF document.
Similarly, to obtain the log document, perform the following actions.
- Invoke the
CreatePDFResultobject’sgetLogDocumentmethod. This returns acom.adobe.idp.Documentobject. - Invoke the
com.adobe.idp.Documentobject’scopyToFilemethod to extract the log document.
- Invoke the
See also
Quick Start (SOAP mode): Converting a PostScript file to a PDF document using the Java API
Converting a PostScript file to PDF using the web service API converting-a-postscript-file-to-pdf-using-the-web-service-api
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.note note NOTE Replace localhostwith the IP address of the server hosting AEM Forms. -
Create a Distiller service client.
-
Create a
DistillerServiceClientobject by using its default constructor. -
Create a
DistillerServiceClient.Endpoint.Addressobject by using theSystem.ServiceModel.EndpointAddressconstructor. 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 thelc_versionattribute. This attribute is used when you create a service reference. However, specify?blob=mtomto use MTOM. -
Create a
System.ServiceModel.BasicHttpBindingobject by getting the value of theDistillerServiceClient.Endpoint.Bindingfield. Cast the return value toBasicHttpBinding. -
Set the
System.ServiceModel.BasicHttpBindingobject’sMessageEncodingfield 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
DistillerServiceClient.ClientCredentials.UserName.UserName. - Assign the corresponding password value to the field
DistillerServiceClient.ClientCredentials.UserName.Password. - Assign the constant value
HttpClientCredentialType.Basicto the fieldBasicHttpBindingSecurity.Transport.ClientCredentialType. - Assign the constant value
BasicHttpSecurityMode.TransportCredentialOnlyto the fieldBasicHttpBindingSecurity.Security.Mode.
- Assign the AEM forms user name to the field
-
-
Retrieve the file to convert.
- Create a
BLOBobject by using its constructor. ThisBLOBobject is used to store the file to convert to a PDF document. - Create a
System.IO.FileStreamobject by invoking its constructor and passing a string value that represents the file location and the mode to open the file in. - Create a byte array that stores the content of the
System.IO.FileStreamobject. You can determine the size of the byte array by getting theSystem.IO.FileStreamobject’sLengthproperty. - Populate the byte array with stream data by invoking the
System.IO.FileStreamobject’sReadmethod and passing the byte array, the starting position, and the stream length to read. - Populate the
BLOBobject by assigning itsMTOMproperty with the contents of the byte array.
- Create a
-
Invoke the PDF creation operation.
Invoke the
DistillerServiceServiceobject’sCreatePDF2method and pass the following required values:- The
BLOBobject that represents the PS file to convert - A string that contains the path name of the file to be convert
- A string object that contains the Adobe PDF settings to be used (for example,
Standard) - A string object that contains the security settings to be used (for example,
No Security) - An optional
BLOBobject that contains settings to be applied while generating the PDF document - An optional
BLOBobject that contains metadata information to be applied to the PDF document - A
BLOBoutput parameter used to store the PDF document - A
BLOBoutput parameter used to store the log
- The
-
Save the PDF document.
- Create a
System.IO.FileStreamobject 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. - Create a byte array that stores the content of the
BLOBobject that was returned by theCreatePDF2method (the output parameter). Populate the byte array by getting the value of theBLOBobject’sMTOMdata member. - Create a
System.IO.BinaryWriterobject by invoking its constructor and passing theSystem.IO.FileStreamobject. - Write the contents of the byte array to a PDF file by invoking the
System.IO.BinaryWriterobject’sWritemethod and passing the byte array.
- Create a
See also
Invoking AEM Forms using SwaRef