Invoking Output Service (transformPDF) via EJB

This sample provides the basics for invoking the transformPDF method of the LiveCycle OutputService.

This sample assumes you are using LiveCycle on Jboss. If you are using a different Java server, you will need to modify a few paramaters, but the basics are the same.

The transformPDF service transforms a interactive PDF (PDF Form) to a non-interactive PDF.

Environment Setup
1. Copy the following required jar files from your LiveCycle Installation to your {ColdFusion Install Directory}\wwwroot\WEB-INF\lib.
jbossall-client.jar [C:\Adobe\LiveCycle8\jboss\client]
adobe-utilities.jar [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\jboss]
adobe-output-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-usermanager-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]
adobe-livecycle-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]

2. Restart ColdFusion Application Service

transformPDF_EJB.cfm
<!—
Modify these three variables to match your environment
** Be sure the fileInput is a PDF Form
—>
<cfset EJB_ENDPOINT = "jnp://68.175.120.115:1099">
<cfset fileInput = "C:\temp\test.pdf">
<cfset fileOutput = "C:\temp\output.pdf">

<cfscript>
// Create ServiceClientFactoryProperties
serviceClientFactoryProperties = CreateObject("java","com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties");
connectionProps = CreateObject("java","java.util.Properties").init();
connectionProps.setProperty(serviceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, EJB_ENDPOINT);
connectionProps.setProperty(serviceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, serviceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(serviceClientFactoryProperties.DSC_SERVER_TYPE, "Jboss");
connectionProps.setProperty(serviceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(serviceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
</cfscript>

<cfscript>
// Initialize ServiceClientFactory with serviceClientFactoryProperties
myFactory = CreateObject("java","com.adobe.idp.dsc.clientsdk.ServiceClientFactory").createInstance(connectionProps);

// Initialize FileInputStream with fileInput Variable
fileInputStream = CreateObject("java","java.io.FileInputStream").init(fileInput);

// Initialize OutputClient with ServiceClientFactory properties
outClient = CreateObject("java","com.adobe.livecycle.output.client.OutputClient").init(myFactory);

// Set inPDF Document
inPDF = CreateObject("java","com.adobe.idp.Document").init(fileInputStream);

// Set outPDF Document For Result Handling
outPDF = CreateObject("java","com.adobe.idp.Document");

// transformPDF Parameter Settings: You can avoid these properties and simply cast nulls as in the commented invoke below
TransformationFormat = CreateObject("java","com.adobe.livecycle.output.client.TransformationFormat");
PDFARevisionNumber = CreateObject("java","com.adobe.livecycle.output.client.PDFARevisionNumber");
PDFAConformance = CreateObject("java","com.adobe.livecycle.output.client.PDFAConformance");

// Initiate The transformPDF Method
outPDF = outClient.transformPDF(inPDF,TransformationFormat.PDF,PDFARevisionNumber.Revision_1,"",PDFAConformance.A);
// If you want to use null make sure you JavaCast
//outPDF = outClient.transformPDF(inPDF,TransformationFormat.PDF,JavaCast( "null", 0 ),"",JavaCast( "null", 0 ));

// Initialize FileOutputStream with fileOutput Variable
fileOutputStream = CreateObject("java","java.io.File").init(fileOutput);

// Write The File…
outPDF.copyToFile(fileOutputStream);
</cfscript>

You can also download the source here Download Source