Article summary

Summary Discusses how to use the Output Service Java API for AEM Forms to create a PDF document.  
Digital Marketing Solution(s) Adobe Experience Manager Forms 6.4
Audience Developer
Required Skills Java, HTML, JavaScript
Version 6.4


You can use the AEM Forms Output service to create a PDF document that is based on a form design (an XDP file created in Designer) and XML form data that you provide. The PDF document that is created by the Output service is not an interactive PDF document. That is, a user cannot enter or modify form data.

The following illustrations shows the PDF that is created in this article.


An PDF document that is created by the Output Service


You can use the Output Service by using both Experience Manager with Form bundles installed and by using AEM Forms for J2EE. 

The Output service lets you output documents as PDF (including PDF/A documents), PostScript, Printer Control Language (PCL), and the following label formats:

  • Zebra - ZPL
  • Intermec - IPL
  • Datamax - DPL
  • TecToshiba - TPCL

Using the Output service, you can merge XML form data with a form design and output the document to a network printer or file.

Using AEM Forms for J2EE

This section of the article discusses how to use the Output Service that is part of the J2EE installation. Before reading this, ensure that you have AEM Forms for J2EE installed. For information, see AEM 6.4 Forms User Guide.

When invoking the Output Service on AEM Forms for J2EE, you use this Output Service API

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

The following JAR files must be added to your project’s classpath:

  • adobe-livecycle-client.jar
  • adobe-usermanager-client.jar
  • adobe-output-client.jar
  • adobe-utilities.jar (Required if LiveCycle is deployed on JBoss)
  • jbossall-client.jar (Required if LiveCycle is deployed on JBoss)

If AEM Forms for J2EE is deployed on a supported J2EE application server that is not JBoss, you will need to replace the adobe-utilities.jar and jbossall-client.jar files with JAR files that are specific to the J2EE application server on which AEM Forms for J2EE is deployed.

Create an Output Client object
Before you can programmatically perform an Output service operation, you must create an Output service client object. If you are using the Java API, create an OutputClient object. 

Reference an XML data source
To merge data with the form design, you must reference an XML data source that contains data. An XML element must exist for every form field that you plan to populate with data. The XML element name must match the field name. An XML element is ignored if it does not correspond to a form field or if the XML element name does not match the field name. It is not necessary to match the order in which the XML elements are displayed if all XML elements are specified.

Consider the following example form created in Designer.

An Example Form created in Designer

To merge data into this form design, you must create an XML data source that corresponds to the form. The following XML represents a data source that corresponds to the example form. (In this example, only 2 form fields are populated). 

<?xml version="1.0" encoding="UTF-8"?>
   <txtOrderedByContactName>Tony Blue</txtOrderedByContactName>

Set PDF run-time options

Set the file URI option when creating a PDF document. This option specifies the name and location of the PDF file that the Output service generates.

Note: Instead of setting the file URI run-time option, you can programmatically retrieve the PDF document from the complex data type that is returned by the Output service. However, by setting the file URI run-time option, you do not need to create application logic that programmatically retrieves the PDF document.

Set rendering run-time options

You can set rendering run-time options when creating a PDF document. Although these options are not required (unlike PDF run-time options that are required), you can perform tasks such as improving the performance of the Output service. For example, you can cache the form design that the Output service uses in order to improve its performance.

If you use a tagged Acrobat form as input, you cannot use the Output service Java or web service API to turn off the tagged setting. If you attempt to programmatically set this option to false, the result PDF document is still tagged.

Generate a PDF document using the Java API

The following Java code shows how to invoke the Output Service by using the Java API. 

    * This Java Quick Start uses the SOAP mode and contains the following JAR files  in the class path: 
    * 1. adobe-output-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 the LiveCycle Server is not deployed 
    * on JBoss) 
    * 6. activation.jar (required for SOAP mode) 
    * 7. axis.jar (required for SOAP mode) 
    * 8. commons-codec-1.3.jar (required for SOAP mode) 
    * 9.  commons-collections-3.1.jar  (required for SOAP mode) 
    * 10. commons-discovery.jar (required for SOAP mode) 
    * 11. commons-logging.jar (required for SOAP mode) 
    * 12. dom3-xml-apis-2.5.0.jar (required for SOAP mode) 
    * 13. jaxen-1.1-beta-9.jar (required for SOAP mode) 
    * 14. jaxrpc.jar (required for SOAP mode) 
    * 15. log4j.jar (required for SOAP mode) 
    * 16. mail.jar (required for SOAP mode) 
    * 17. saaj.jar (required for SOAP mode) 
    * 18. wsdl4j.jar (required for SOAP mode) 
    * 19. xalan.jar (required for SOAP mode) 
    * 20. xbean.jar (required for SOAP mode) 
    * 21. xercesImpl.jar (required for SOAP mode) 
    *  These JAR files are located in the following path: 
    * <install directory>/sdk/client-libs/common 
    * The adobe-utilities.jar file is located in the following path: 
    * <install directory>/sdk/client-libs/jboss 
    * The jbossall-client.jar file is located in the following path: 
    * <install directory>/jboss/client 
    * SOAP required JAR files are located in the following path: 
    * <install directory>/sdk/client-libs/thirdparty 
    * If you want to invoke a remote Server instance and there is a 
    * firewall between the client application and the server, then it is  
    * recommended that you use the SOAP mode. When using the SOAP mode,  you have to include these additional JAR files 


import java.util.Properties;

import com.adobe.livecycle.output.client.*; 
import java.util.*; 
import com.adobe.idp.Document; 
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory; 
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties; 

public class CreatePDFDocumentSOAP {

	public static void main(String[] args) { 
	     //Set connection properties                                 
	     Properties connectionProps = new Properties(); 
	     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "http://localhost:8080");  
	     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss"); 
	     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator"); 
	     connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password"); 
	     //Create a ServiceClientFactory object 
	     ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps); 
	     //Create an OutputClient object 
	     OutputClient outClient = new OutputClient(myFactory);  
	     //Reference form data                         
	     FileInputStream fileInputStream = new FileInputStream("C:\\Adobe\\Loan.xml");     
	     Document inXMData = new Document (fileInputStream); 
	     //Set PDF run-time options     
	     PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec(); 
	     //Set rendering run-time options 
	     RenderOptionsSpec pdfOptions = new RenderOptionsSpec();  
	     //Create a PDF document             
	     OutputResult outputDocument = outClient.generatePDFOutput( 
	     //Retrieve the results of the operation 
	     Document metaData = outputDocument.getStatusDoc(); 
	     File myFile = new File("C:\\Adobe\\Output.xml"); 
	     catch (Exception ee) 

The following video shows this code successfully creating a PDF document. 

Invoking the AEM Forms for J2EE Output Service

Invoking the AEM Forms for J2EE Output Service
Show how to use the Java API to invoke the Output Service


To consume the Output Service by using AEM Forms for OSGi, see this document: Developing with Output and Forms Services in AEM Forms.

See also

Join the AEM community at: Adobe Experience Manager Community