Passing Documents located in the Repository to the Output Service

The Output service renders a non-interactive PDF form that is based on a form design that is typically saved as an XDP file and created in Designer. As of LiveCycle ES2.5, you can pass a com.adobe.idp.Document object that contains the form design to the Output service. The Output service then renders the form design located in the com.adobe.idp.Document object.

An advantage of passing a com.adobe.idp.Document object to the Output service is that other LiveCycle service operations return a com.adobe.idp.Document instance. That is, you can get a com.adobe.idp.Document instance from another service operation and render it. For example, assume that an XDP file is stored in the LiveCycle repository, as shown in the following illustration.

The FormsFolder folder is a user-defined location in the LiveCycle repository (this location is an example and does not exist by default). In this example, a form design named Loan.xdp is located in this folder. In addition to the form design, other form collateral such as images can be stored in this location. The path to a resource located in the LiveCycle repository is:

Applications/Application-name/Application-version/Folder.../Filename

You can programmatically retrieve Loan.xdp from the LiveCycle repository and pass it to the Output service within a com.adobe.idp.Document object.

You can create a PDF based on an XDP file located in the repository using one of two ways. You can pass the XDP loction by reference or you can programmatically retrieve the XDP from the repository and pass it to the Output service within an XDP file.

Quick Start (EJB mode): Creating a PDF document based on an application XDP file using the Java API (shows how to pass the location of the XDP file by reference).

Quick Start (EJB mode): Passing a document located in the LiveCycle Repository to the Output service using the Java API (shows how to programmatically retrieve the XDP file from the LiveCycle Repository and pass it to the Output service within a com.adobe.idp.Document instance). (This section discusses how to perform this task)

Remarque : For more information about the Forms service, see Services Reference for LiveCycle.

Summary of steps

To pass a document obtained from the LiveCycle repository to the Output service, perform the following tasks:

  1. Include project files.

  2. Create a Output and a Document Management Client API object.

  3. Retrieve the form design from the LiveCycle repository.

  4. Render the non-interactive PDF form.

  5. Perform an action with the data stream.

Include project files

Include the necessary files to your development project. If you are creating a client application by using Java, include the necessary JAR files. If you are using web services, include the proxy files.

Create an Output and a Document Management Client API object

Before you can programmatically perform a Output service API operation, create a Output Client API object. Also, because this workflow retrieves an XDP file from Content Services (deprecated), create a Document Management API object.

Retrieve the form design from the LiveCycle Repository

Retrieve the XDP file from the LiveCycle Repository by using the Repository API. (See Reading Resources.)

The XDP file is returned within a com.adobe.idp.Document instance (or a BLOB instance if you are using web services). You can then pass the com.adobe.idp.Document instance o the Output service.

Render the non-interactive PDF form

To render a non-interactive form, pass the com.adobe.idp.Document instance that was returned using the LiveCycle Repository API.

Remarque : Two new methods named generatePDFOutput2 and generatePrintedOutput2 accept a com.adobe.idp.Document object that contains a form design. You can also pass a com.adobe.idp.Document that contains the form design to the Output service when sending a print stream to a network printer.

Perform an action with the form data stream

You can save the non-interactive form as a PDF file. The form can be viewed in Adobe Reader or Acrobat.

Pass documents located in the Repository to the Output Service using the Java API

Pass a document retrieved from the Repository by using the Output service and Repository API (Java):

  1. Include project files.

    Include client JAR files, such as adobe-output-client.jar and adobe-repository-client.jar, in your Java project’s class path.

  2. Create an Output and a Document Management Client API object.

    • Create a ServiceClientFactory object that contains connection properties. (See Setting connection properties.)

    • Create an OutputClient object by using its constructor and passing the ServiceClientFactory object.

    • Create a DocumentManagementServiceClientImpl object by using its constructor and passing the ServiceClientFactory object.

  3. Retrieve the form design from the LiveCycle Repository.

    Invoke the ResourceRepositoryClient object’s readResourceContent method and pass a string value that specifies the URI location to the XDP file. For example, /Applications/FormsApplication/1.0/FormsFolder/Loan.xdp. This value is a mandatory. This method returns a com.adobe.idp.Document instance that represents the XDP file.

  4. Render the non-interactive PDF form.

    Invoke the OutputClient object’s generatePDFOutput2 method and pass the following values:

    • A TransformationFormat enumeration value. To generate a PDF document, specify TransformationFormat.PDF.

    • A string value that specifies the content root where the additional resources such as images are located. For example, repository:///Applications/FormsApplication/1.0/FormsFolder/.

    • A com.adobe.idp.Document object that represents the form design (use the instance returned by the ResourceRepositoryClient object’s readResourceContent method).

    • A PDFOutputOptionsSpec object that contains PDF run-time options.

    • A RenderOptionsSpec object that contains rendering run-time options.

    • The com.adobe.idp.Document object that contains the XML data source that contains data to merge with the form design.

    The generatePDFOutput2 method returns an OutputResult object that contains the results of the operation.

  5. Perform an action with the form data stream.

    • Retrieve a com.adobe.idp.Document object that represents the non-interactive form by invoking the OutputResult object’s getGeneratedDoc method.

    • Create a java.io.File object that contains the results of the operation. Ensure that the file name extension is .pdf.

    • Invoke the com.adobe.idp.Document object’s copyToFile method to copy the contents of the com.adobe.idp.Document object to the file (ensure that you use the com.adobe.idp.Document object that was returned by the getGeneratedDoc method).