Posts in Category "Forms Service"

Invoking Forms Service (renderPDFForm) via EJB

This sample provides the basics for invoking the renderPDFForm method of the LiveCycle FormsService.

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.

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]
adobe-forms-client [C:\Adobe\LiveCycle8\LiveCycle_ES_SDK\client-libs\common]

2. Restart ColdFusion Application Service

renderForm_EJB.cfm
<!—
Modify these three variables to match your environment
** Be sure the fileInput is a PDF Form XDP
—>

<cfset EJB_ENDPOINT = "jnp://68.175.120.115:1099">

<!— Document Parameters —>
<cfset inXDP = "CAR.xdp"> <!– PDF Form File Name Source: Do Not Include Path Info —>
<cfset inXML = "C:\temp\CAR.xml">
<cfset outPDF = "C:\temp\CAR1.pdf">

<!— URLSpec Parameters —>
<cfset applicationWebRoot = ”>
<cfset targetURL = ”>
<cfset contentRootURI = ‘C:\Adobe\forms\’> <!— The Directory of the inXDP file located on the LiveCycle installed server —>
<cfset baseURL = ”>

<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");

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

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

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

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

PDFFormRenderSpec = CreateObject("java","com.adobe.livecycle.formsservice.client.PDFFormRenderSpec").init();
PDFVersion = CreateObject("java","com.adobe.livecycle.formsservice.client.PDFVersion");
PDFFormRenderSpec.setPDFVersion(PDFVersion.PDFVersion_1_5);

// Create URLSpec Object
URLSpec = CreateObject("java","com.adobe.livecycle.formsservice.client.URLSpec").init();
URLSpec.setApplicationWebRoot(applicationWebRoot);
URLSpec.setContentRootURI(contentRootURI);
URLSpec.setTargetURL(targetURL);

// Initiate The renderPDFForm Method
FormsResult = formsClient.renderPDFForm(inXDP,inXML,PDFFormRenderSpec,URLSpec,JavaCast( "null", "" ));

// Set outPDF Document For Result Handling
FormsResultPDF = FormsResult.getOutputContent();

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

FormsResultPDF.copyToFile(fileOutputStream);
</cfscript>

You can also download the source here Download Source