18 May 2009
Familiarity with creating Java applications in Eclipse.
All
In this tutorial, you will learn how to invoke a LiveCycle ES SOAP endpoint to convert a PostScript file into a PDF file. Scott MacDonald and I created this tutorial to help LiveCycle ES developers better understand the steps needed to use Quick Start guides available from the LiveCycle ES area of the Adobe Developer Connection, including how to download and configure the code samples, configure the right JAR files, and set user permissions.
You will need the following LiveCycle ES client SDK JAR files for this tutorial:
These JAR files are located in the following path: {install directory}/LiveCycle<version>/LiveCycle_ES_SDK/client-libs/common
This file is located in the following path:
{install directory}/LiveCycle<version>/LiveCycle_ES_SDK/client-libs/jboss
This file is located in the following path:
{install directory}/LiveCycle<version>/jboss/client
(Use a different JAR file if LiveCycle ES is not deployed on JBoss.)
You will also need the third-party JAR files to use the SOAP stack rather than EJB endpoints. If you want to invoke a remote LiveCycle ES instance and there is a firewall between the client application and LiveCycle ES, then it is recommended that you use the SOAP mode. When using the SOAP mode, you have to include additional JAR files located in the following path:
{install directory}/LiveCycle<version>/LiveCycle_ES_SDK/client-libs/thirdparty
For information about the SOAP and EJB modes, see Setting connection properties in Programming with LiveCycle ES.
Follow these steps to create the application.
package org.duanesworldtv.samples;
/*
* This Java Quick Start uses the following JAR files
* 1. adobe-distiller-client.jar
* 2. adobe-livecycle-client.jar
* 3. adobe-usermanager-client.jar
* 4. adobe-utilities.jar
* 5. jbossall-client.jar (use a different JAR file if LiveCycle ES is not deployed
* on JBoss)
*
* These JAR files are located in the following path:
* /LiveCycle<version>/LiveCycle_ES_SDK/client-libs
*
* For complete details about the location of these JAR files,
* see "Including LiveCycle ES library files" in Programming
* with LiveCycle ES
*/
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import com.adobe.livecycle.generatepdf.client.CreatePDFResult;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.distiller.client.DistillerServiceClient;
public class CreatePDF {
public static void main(String[] args)
{
try
{
//Set connection properties required to invoke LiveCycle ES
Properties ConnectionProps = new Properties();
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "http://{your_server_IP}:{HTTP_PORT}");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "{username_of_privileged_user}");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "{password}");
// Create a ServiceClientFactory instance
ServiceClientFactory factory = ServiceClientFactory.createInstance(ConnectionProps);
DistillerServiceClient disClient = new DistillerServiceClient(factory );
// Get a PS file document to convert to a PDF document and populate a com.adobe.idp.Document object
String inputFileName = "/Users/duane/Desktop/eclipse/workspace/JavaOne2009-docs/test.ps";
FileInputStream fileInputStream = new FileInputStream(inputFileName);
Document inDoc = new Document(fileInputStream);
//Set run-time options
String adobePDFSettings = "Standard";
String securitySettings = "No Security";
//Convert a PS file into a PDF file
CreatePDFResult result = new CreatePDFResult();
result = disClient.createPDF(
inDoc, inputFileName, adobePDFSettings,
securitySettings, null, null
);
//Get the newly created document
Document createdDocument = result.getCreatedDocument();
//Save the PDF file
createdDocument.copyToFile(new File("/Users/duane/Desktop/eclipse/workspace/JavaOne2009-docs/DuanesWorldTest.pdf"));
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Be sure to replace the package name with your own package name.
There are a couple of things you need to be aware of with respect to these JARs.
First, the JARs must be from the same release of LiveCycle as the instance you are going to connect to. JARs from LiveCycle ES, version 8.0, for example, might not always work with a LiveCycle ES, version 8.2.1 instance.
Second, the JARs are not all found in the same location. (See Installing the required JAR files for details.)
I put the JAR files into a parallel directory that I created under my Eclipse workspace called "JavaOne2009_libs". This allows me to easily use these JAR files for multiple projects.
//Set connection properties required to invoke LiveCycle ES
Properties ConnectionProps = new Properties();
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "http://{your_server_ip}:{http_port}");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "{username_of_privileged_user}");
ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "{password}");
To run the code in this tutorial, you will need to update the roles assigned to kvarsen. To do this, you must have administrator access to the LiveCycle ES server you wish to connect to.
You are almost ready to run the code.
// Get a PS file document to convert to a PDF document and
populate a com.adobe.idp.Document object
String inputFileName =
"/Users/duane/Desktop/eclipse/workspace/JavaOne2009-docs/test.ps";
//Save the PDF file
createdDocument.copyToFile(new File("/Users/duane/Desktop/eclipse/workspace/JavaOne2009-docs/DuanesWorldTest.pdf"));
Now that you have a better idea of how to invoke a LiveCycle ES SOAP endpoint, you may want to try some of the other LiveCycle Remoting Quick Starts:
You can also explore the LiveCycle ES DSK help documentation and APIs.

This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.