The following code example renders a form that is based on fragments. The name of the form design is POFragment.xdp and it is located in the LiveCycle ES repository (the XDP file is stored in a folder named FormsFolder located in the repository). Also the fragments that the POFragment form references must also be located in the repository. (See Rendering Forms Based on Fragments.)/** This Java Quick Start uses the following JAR files* 1. adobe-forms-client.jar* 2. adobe-livecycle-client.jar* 3. adobe-usermanager-client.jar** (Because Forms quick starts are implemented as Java servlets, it is* not necessary to include J2EE specific JAR files - the Java project* that contains this quick start is exported as a WAR file which* is deployed to the J2EE application server)** These JAR files are located in the following path:* <install directory>/Adobe/LiveCycle8/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.IOException;import javax.servlet.Servlet;import javax.servlet.ServletException;import javax.servlet.ServletOutputStream;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.adobe.livecycle.formsservice.client.*;import java.util.*;import java.io.InputStream;import com.adobe.idp.Document;import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;public class RenderFormFragments extends HttpServlet implements Servlet {public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {doPost(req,resp);}public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {try{//Set connection properties required to invoke LiveCycle ESProperties connectionProps = new Properties();connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");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");//Create a ServiceClientFactory objectServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);//Create a FormsServiceClient objectFormsServiceClient formsClient = new FormsServiceClient(myFactory);//Set the parameter values for the renderPDFForm methodString formName = "FormsFolder/POFragment.xdp";byte[] cData = "".getBytes();Document oInputData = new Document(cData);//Cache the PDF formPDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();pdfFormRenderSpec.setCacheEnabled(new Boolean(true));//Specify URI values that are required to render a form//design based on fragmentsURLSpec uriValues = new URLSpec();uriValues.setApplicationWebRoot("http://localhost:8080/FormsServiceClientApp");uriValues.setContentRootURI("repository:///");uriValues.setTargetURL("http://localhost:8080/FormsServiceClientApp/HandleData");//Invoke the renderPDFForm method and write the//results to a client web browserFormsResult formOut = formsClient.renderPDFForm(formName, //formQueryoInputData, //inDataDocpdfFormRenderSpec, //PDFFormRenderSpecuriValues, //urlSpecnull //attachments);//Create a Document object that stores form dataDocument myData = formOut.getOutputContent();//Get the content type of the response and//set the HttpServletResponse object’s content typeString contentType = myData.getContentType();resp.setContentType(contentType);//Create a ServletOutputStream objectServletOutputStream oOutput = resp.getOutputStream();//Create an InputStream objectInputStream inputStream = myData.getInputStream();//Get the size of the InputStream objectint size = inputStream.available();//Create and populate a byte arraybyte[] data = new byte[size];inputStream.read(data);//Write the data stream to the web browseroOutput.write(data);}catch (Exception e) {System.out.println("The following exception occurred: "+e.getMessage());}}}
| Programming with LiveCycle ES (LiveDocs) |
| Adobe LiveCycle ES Update 1 |
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000072.html