Output Service Java API Quick Start (SOAP) output-service-java-api-quick-start-soap
Java API Quick Start(SOAP) is available for the Output service.
Quick Start (SOAP mode): Creating a PDF document using the Java API
Quick Start (SOAP mode): Creating a PDF document based on an application XDP file using the Java API
Quick Start (SOAP mode): Creating a PDF/A document using the Java API
Quick Start (SOAP mode): Passing documents to the Output Service using the Java API
Quick Start (SOAP mode): Creating a PDF document based on fragments using the Java API
Quick Start (SOAP mode): Printing to a file using the Java API
Quick Start (SOAP mode): Sending a print stream to a network printer using the Java API
Quick Start (SOAP mode): Creating multiple PDF files using the Java API
Quick Start (SOAP mode): Creating search rules using the Java API
Quick Start (SOAP mode): Transforming a PDF document using the Java API
AEM Forms operations can be performed using the AEM Forms strongly typed API and the connection mode should be set to SOAP.
Quick Start (SOAP mode): Creating a PDF document using the Java API quick-start-soap-mode-creating-a-pdf-document-using-the-java-api
The following Java code example creates a PDF document named Loan.pdf. This PDF document is based on a form design named Loan.xdp and an XML data file named Loan.xml. The Loan.pdf is written to the C:\ΓΫΆΉΚΣΖ΅ folder located on the J2EE application server hosting AEM Forms, not the client computer. (See Creating PDF Documents.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreatePDFDocument {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setLinearizedPDF(true);
β pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
β //Create a PDF document
β OutputResult outputDocument = outClient.generatePDFOutput(
β TransformationFormat.PDF,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Retrieve the results of the operation
β Document metaData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Output.xml");
β metaData.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Creating a PDF document based on an application XDP file using the Java API quick-start-soap-mode-creating-a-pdf-document-based-on-an-application-xdp-file-using-the-java-api
The following Java code example creates a PDF document named Loan.pdf. This PDF document is based on a form design named Loan.xdp and an XML data file named Loan.xml. The XDP file is deployed as part of an AEM Forms application named Applications/FormsApplication
. Notice that the URI path is repository:///Applications/FormsApplication/1.0/FormsFolder/
. The Loan.pdf is written to the C:\ΓΫΆΉΚΣΖ΅ folder located on the J2EE application server hosting AEM Forms, not the client computer. (See Creating PDF Documents.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * These JAR files are in the following path:
β * <install directory>/ΓΫΆΉΚΣΖ΅/adobe_experience_manager_forms/SDK/client-libs/common
β *
β * <install directory>/ΓΫΆΉΚΣΖ΅/adobe_experience_manager_forms/SDK/client-libs/jboss
β *
β * <install directory>/ΓΫΆΉΚΣΖ΅/adobe_experience_manager_forms/jboss/bin/client
β *
β * If you want to invoke a remote AEM Forms instance and there is a
β * firewall between the client application and AEM Forms, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/ΓΫΆΉΚΣΖ΅/adobe_experience_manager_forms/SDK/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreatePDFDocumentFromLCApp {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setLinearizedPDF(true);
β pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
β //Create a PDF document -- reference an XDP file named Loan.xdp that is deployed as part of
β //a AEM Forms application named Applications/FormsApplication. The XDP file is located
β //in a folder named FormsFolder
β OutputResult outputDocument = outClient.generatePDFOutput(
β TransformationFormat.PDF,
β "Loan.xdp",
β "repository:///Applications/FormsApplication/1.0/FormsFolder/",
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Retrieve the results of the operation
β Document metaData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Output.xml");
β metaData.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Passing a document in the Repository to the Output service using the Java API quick-start-soap-mode-passing-a-document-located-in-the-repository-to-the-output-service-using-the-java-api
The following Java code retrieves an XDP file from the Repository and passes it to the Output service within com.adobe.idp.Document
instance. The XDP file is deployed as part of a AEM Forms application named Applications/FormsApplication
. Notice that the URI path is repository:///Applications/FormsApplication/1.0/FormsFolder/
.
Also notice the content root value repository:///Applications/FormsApplication/1.0/FormsFolder/
is passed to the OutputClient
΄Η²ϊΒα±π³¦³Ωβs generatePDFOutput2
method (the second parameter). This value is passed to the Output service to inform the Output service that form collateral, such as images, are stored in this location.
generatePrintedOutput2
method.The Loan.pdf is written to the C:\ΓΫΆΉΚΣΖ΅ folder located on the J2EE application server hosting AEM Forms. (See Passing Documents in the Repository to the Output Service.)
β/*
β * 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-repository-client.jar
β * 3. adobe-livecycle-client.jar
β * 4. adobe-usermanager-client.jar
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreatePDFFFromRepository {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf"); // this PDF form is saved on the server
β //Get the form design from the AEM Forms Repository
β Document formDesign = GetFormDesign(myFactory);
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setLinearizedPDF(true);
β pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
β //Create a non-interactive PDF document
β OutputResult outputDocument = outClient.generatePDFOutput2(
β TransformationFormat.PDF,
β "repository:///Applications/FormsApplication/1.0/FormsFolder/",
β formDesign,
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Save the non-interactive PDF form as a PDF file on the client computer
β Document pdfForm = outputDocument.getGeneratedDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β pdfForm.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β // Retrieve the form design from the following Repository path:
β // /Applications/FormsApplication/1.0/FormsFolder/Loan.xdp
β private static Document GetFormDesign(ServiceClientFactory myFactory)
β {
β try{
β // Create a ResourceRepositoryClient object using the service client factory
β ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);
β // Specify the path in the Repository to Loan.xdp
β String resourceUri = "/Applications/FormsApplication/1.0/FormsFolder/Loan.xdp";
β // Retrieve the XDP file
β Document doc = repositoryClient.readResourceContent(resourceUri);
β //Return the Document instance
β return doc;
β }
β catch(Exception e)
β {
β e.printStackTrace();
β }
β return null;
β }
β}
Quick Start (SOAP mode): Creating a PDF document using the Java API quick_start_soap_mode_creating_a_pdf_document_using_the_java_api-1
The following Java code example creates a PDF document named Loan.pdf. This PDF document is based on a form design named Loan.xdp and an XML data file named Loan.xml. The Loan.pdf is written to the C:\ΓΫΆΉΚΣΖ΅ folder located on the J2EE application server hosting AEM Forms, not the client computer. (See Creating PDF Documents.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * SOAP required JAR files are in the following path:
β * <install directory>/sdk/client-libs/thirdparty
β *
β * If you want to invoke a remote Forms 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
β *
β * For information about the SOAP
β * mode, see "Setting connection properties" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
β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) {
β try{
β //Set connection properties required to invoke AEM Forms using SOAP mode
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setLinearizedPDF(true);
β pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
β //Create a PDF document
β OutputResult outputDocument = outClient.generatePDFOutput(
β TransformationFormat.PDF,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Retrieve the results of the operation
β Document metaData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Output.xml");
β metaData.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Creating a PDF/A document using the Java API quick-start-soap-mode-creating-a-pdf-a-document-using-the-java-api
The following Java code example creates a PDF/A document named LoanArchive.pdf. This PDF document is based on a form design named Loan.xdp and an XML data file named Loan.xml. The LoanArchive.pdf is written to the C:\ΓΫΆΉΚΣΖ΅ folder located on the J2EE application server hosting AEM Forms, not the client computer. (See Creating PDF/A Documents.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreatePDFADocument {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference an XML data source to merge with the form design
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\LoanArchive.pdf");
β //Set rendering run-time options
β RenderOptionsSpec pdfAOptions = new RenderOptionsSpec();
β pdfAOptions.setPDFAConformance(PDFAConformance.A);
β pdfAOptions.setPDFARevisionNumber(PDFARevisionNumber.Revision_1);
β //Create a PDF/A document
β OutputResult outputDocument = outClient.generatePDFOutput(
β TransformationFormat.PDFA,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β outputOptions,
β pdfAOptions,
β inXMData
β );
β //Write the results of the operation to OutputLog.xml
β Document resultData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\OutputLog.xml");
β resultData.copyToFile(myFile);
β }catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Passing documents to the Output Service using the Java API quick-start-soap-mode-passing-documents-to-the-output-service-using-the-java-api
The following Java quick start retrieves the file Loan.xdp from Content Services. This XDP file is in the space /Company Home/Form Designs
. The XDP file is returned in a com.adobe.idp.Document
instance. The com.adobe.idp.Document
instance is passed to the Output service. The non-interactive form is saved as a PDF file named *Loan.pdf *on the client computer. Because the File URI option is set, the PDF file *Loan.pdf *is also saved on the J2EE application server hosting AEM Forms. (See Passing Documents in Content Services ES2 to the Output Service.)
β/*
β * 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-contentservices-client.jar
β * 3. adobe-livecycle-client.jar
β * 4. adobe-usermanager-client.jar
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.contentservices.client.CRCResult;
βimport com.adobe.livecycle.contentservices.client.impl.DocumentManagementServiceClientImpl;
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreatePDFFFromContentServices {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf"); // this PDF form is saved on the server
β //Get the form design from Content Services
β Document formDesign = GetFormDesign(myFactory);
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setLinearizedPDF(true);
β pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
β //Create a non-interactive PDF document
β OutputResult outputDocument = outClient.generatePDFOutput2(
β TransformationFormat.PDF,
β "C:\\ΓΫΆΉΚΣΖ΅",
β formDesign,
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Save the non-interactive PDF form as a PDF file on the client computer
β Document pdfForm = outputDocument.getGeneratedDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β pdfForm.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β //Retrieve the form design from Content Services ES2
β private static Document GetFormDesign(ServiceClientFactory myFactory)
β {
β try{
β //Create a DocumentManagementServiceClientImpl object
β DocumentManagementServiceClientImpl docManager = new DocumentManagementServiceClientImpl(myFactory);
β //Specify the name of the store and the content to retrieve
β String storeName = "SpacesStore";
β String nodeName = "/Company Home/Form Designs/Loan.xdp";
β //Retrieve /Company Home/Form Designs/Loan.xdp
β CRCResult content = docManager.retrieveContent(
β storeName,
β nodeName,
β "");
β //Return the Document instance
β Document doc =content.getDocument();
β return doc;
β }
β catch(Exception e)
β {
β e.printStackTrace();
β }
β return null;
β }
β}
Quick Start (SOAP mode): Creating a PDF document based on fragments using the Java API quick-start-soap-mode-creating-a-pdf-document-based-on-fragments-using-the-java-api
The following Java code example creates a PDF document that is based on a form design assembled by the Assembler service. The Assembler service assembles fragments in multiple XDP files into a single form design. Application logic that invokes the Assembler service is in a user-defined method named GetFormDesign
. The non-interactive form is saved as a PDF file named *Loan.pdf *on the client computer. (See Creating PDF Documents Using Fragments.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β * 20. adobe-assembler-client.jar
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β *
β * This is the DDX file is used to assemble multiple XDP documents:
β * <?xml version="1.0" encoding="UTF-8"?>
β * <DDX xmlns="https://ns.adobe.com/DDX/1.0/">
β * <XDP result="tuc018result.xdp">
β * <XDP source="tuc018_template_flowed.xdp">
β * <XDPContent insertionPoint="ddx_fragment" source="tuc018_contact.xdp" fragment="subPatientContact" required="false"/>
β * <XDPContent insertionPoint="ddx_fragment" source="tuc018_patient.xdp" fragment="subPatientPhysical" required="false"/>
β * <XDPContent insertionPoint="ddx_fragment" source="tuc018_patient.xdp" fragment="subPatientHealth" required="false"/>
β * </XDP>
β * </XDP>
β * </DDX>
β */
βimport com.adobe.livecycle.assembler.client.AssemblerOptionSpec;
βimport com.adobe.livecycle.assembler.client.AssemblerResult;
βimport com.adobe.livecycle.assembler.client.AssemblerServiceClient;
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreatePDFFromFragments {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Set PDF run-time options
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf"); // this PDF form is saved on the server
β //Get the form design from Assembler service
β Document formDesign = GetFormDesign(myFactory);
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setLinearizedPDF(true);
β pdfOptions.setAcrobatVersion(AcrobatVersion.Acrobat_9);
β //Create a non-interactive PDF document
β OutputResult outputDocument = outClient.generatePDFOutput2(
β TransformationFormat.PDF,
β "C:\\ΓΫΆΉΚΣΖ΅",
β formDesign,
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Save the non-interactive PDF form as a PDF file on the client computer
β Document pdfForm = outputDocument.getGeneratedDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β pdfForm.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β //Retrieve the form design from Assembler service
β private static Document GetFormDesign(ServiceClientFactory myFactory)
β {
β try{
β //Create an AssemblerServiceClient object
β AssemblerServiceClient assemblerClient = new AssemblerServiceClient(myFactory);
β //Create a FileInputStream object based on an existing DDX file
β FileInputStream myDDXFile = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\fragmentDDX.xml");
β //Create a Document object based on the DDX file
β Document myDDX = new Document(myDDXFile);
β //Create a Map object to store the input XDP files
β Map inputs = new HashMap();
β FileInputStream inSource = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\tuc018_template_flowed.xdp");
β FileInputStream inFragment1 = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\tuc018_contact.xdp");
β FileInputStream inFragment2 = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\tuc018_patient.xdp");
β //Create a Document object
β Document myMapSource = new Document(inSource);
β //Create a Document object
β Document inFragment1Doc = new Document(inFragment1);
β //Create a Document object
β Document inFragment2Doc = new Document(inFragment2);
β //Place all the XDP files into the MAP
β inputs.put("tuc018_template_flowed.xdp",myMapSource);
β inputs.put("tuc018_contact.xdp",inFragment1Doc);
β inputs.put("tuc018_patient.xdp",inFragment2Doc);
β //Create an AssemblerOptionsSpec object
β AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec();
β assemblerSpec.setFailOnError(false);
β //Submit the job to Assembler service
β AssemblerResult jobResult = assemblerClient.invokeDDX(myDDX,inputs,assemblerSpec);
β java.util.Map allDocs = jobResult.getDocuments();
β //Retrieve the result PDF document from the Map object
β Document outDoc = null;
β //Iterate through the map object to retrieve the result XDP document
β for (Iterator i = allDocs.entrySet().iterator(); i.hasNext();) {
β // Retrieve the Map object?s value
β Map.Entry e = (Map.Entry)i.next();
β //Get the key name as specified in the
β //DDX document
β String keyName = (String)e.getKey();
β if (keyName.equalsIgnoreCase("tuc018result.xdp"))
β {
β Object o = e.getValue();
β outDoc = (Document)o;
β }
β }
β return outDoc;
β }catch (Exception e) {
β e.printStackTrace();
β }
β return null;
β }
β }
Quick Start (SOAP mode): Printing to a file using the Java API quick-start-soap-mode-printing-to-a-file-using-the-java-api
The following Java code example prints an output stream to a PostScript file named MortgageForm.ps. (See Printing to Files.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class PrintToFile {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference XML data that represents form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inputXML = new Document(fileInputStream);
β //Set print run-time options required to print to a file
β PrintedOutputOptionsSpec printOptions = new PrintedOutputOptionsSpec();
β printOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\MortgageForm.ps");
β //Print the print stream to a PostScript file
β OutputResult outputDocument = outClient.generatePrintedOutput(
β PrintFormat.PostScript,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β null,
β printOptions,
β inputXML);
β //Write the results of the operation to OutputLog.xml
β Document resultData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\OutputLog.xml");
β resultData.copyToFile(myFile);
β System.out.println("AEM Forms printed to MortgageForm.ps");
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Sending a print stream to a network printer using the Java API quick-start-soap-mode-sending-a-print-stream-to-a-network-printer-using-the-java-api
The following Java code example sends a PostScript print stream to a network printer named \Printer1\Printer. Two copies are sent to the printer. (See Sending Print Streams to Printers.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.livecycle.output.client.*;
βpublic class SendToPrinter {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference XML data that represents form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inputXML = new Document(fileInputStream);
β //Set print run-time options required to print to a file
β PrintedOutputOptionsSpec printOptions = new PrintedOutputOptionsSpec();
β //Set the number of copies to print
β printOptions.setCopies(2);
β //Turn on the Staple option
β printOptions.setStaple(Staple.on);
β //Create a PostScript output stream based on the form design named Loan.xdp and
β //the data in the XML file
β OutputResult outputDocument = outClient.generatePrintedOutput(
β PrintFormat.PostScript,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β "C:\\ΓΫΆΉΚΣΖ΅",
β printOptions,
β inputXML);
β //Get a Document object that stores the PostScript print stream
β Document psPrintStream = outputDocument.getGeneratedDoc();
β //Specify the print server and the printer name
β String printServer = "\\\ottprint";
β String printerName = "\\\ottprint\Balsom";
β //Send the PostScript print stream to the printer
β outClient.sendToPrinter(
β psPrintStream,
β PrinterProtocol.SharedPrinter,
β printServer,
β printerName);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Creating multiple PDF files using the Java API quick-start-soap-mode-creating-multiple-pdf-files-using-the-java-api
The following Java code creates multiple PDF files for each data record that is in an XML data file named Loan_data_batch.xml. The files are written to the C:\ΓΫΆΉΚΣΖ΅ directory. The PDF files are written to the C:\ΓΫΆΉΚΣΖ΅ folder located on the J2EE application server hosting AEM Forms, not the client computer. (See Creating Multiple Output Files.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.livecycle.output.client.*;
βpublic class CreateBatchFiles {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data that contains multiple records
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan_data_batch.xml");
β Document inXMData = new Document (fileInputStream);
β //Set run-time options to generate many PDF files
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β outputOptions.setGenerateManyFiles(true);
β outputOptions.setRecordName("LoanRecord");
β //Set rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setCacheEnabled(new Boolean(true));
β //Create multiple PDF files
β OutputResult outputDocument = outClient.generatePDFOutput(
β TransformationFormat.PDF,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Retrieve the results of the operation
β Document metaData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\Output.xml");
β metaData.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Creating search rules using the Java API quick-start-soap-mode-creating-search-rules-using-the-java-api
The following Java code example creates two text patterns that the Output service searches for. The first text pattern is Mortgage. If found, the Output service uses the form design named Mortgage.xdp. The second text pattern is Automobile. If found, the Output service uses the form design named AutomobileLoan.xdp. If neither text pattern is located, the Output service uses the default form design named* Loan.xdp. *(See Creating Search Rules.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class CreateSearchRules {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference form data
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.xml");
β Document inXMData = new Document (fileInputStream);
β //Define two text patterns
β Rule mortageRule = new Rule();
β mortageRule.setPattern("Mortgage");
β mortageRule.setForm("Mortgage.xdp");
β Rule automobileRule = new Rule();
β automobileRule.setPattern("Automobile");
β automobileRule.setForm("AutomobileLoan.xdp");
β //Add the Rules to a List object
β List<Rule> myList = new ArrayList<Rule>();
β myList.add(mortageRule);
β myList.add(automobileRule);
β //Define PDF run-time options which includes Search Rules
β PDFOutputOptionsSpec outputOptions = new PDFOutputOptionsSpec();
β outputOptions.setFileURI("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β outputOptions.setRules(myList);
β outputOptions.setLookAhead(900);
β //Define rendering run-time options
β RenderOptionsSpec pdfOptions = new RenderOptionsSpec();
β pdfOptions.setCacheEnabled(new Boolean(true));
β //Create a PDF document based on multiple form designs
β OutputResult outputDocument = outClient.generatePDFOutput(
β TransformationFormat.PDF,
β "Loan.xdp",
β "C:\\ΓΫΆΉΚΣΖ΅",
β outputOptions,
β pdfOptions,
β inXMData
β );
β //Write the results of the operation to OutputLog.xml
β Document resultData = outputDocument.getStatusDoc();
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\OutputLog.xml");
β resultData.copyToFile(myFile);
β }
β catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Transforming a PDF document using the Java API quick-start-soap-mode-transforming-a-pdf-document-using-the-java-api
The following Java code example transforms an interactive PDF document named Loan.pdf to a non-interactive PDF document named NonInteractiveLoan.pdf. (See Flattening PDF Documents.)
β/*
β * 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. activation.jar (required for SOAP mode)
* 5. axis.jar (required for SOAP mode)
* 6. commons-codec-1.3.jar (required for SOAP mode)
* 7. commons-collections-3.2.jar (required for SOAP mode)
* 8. commons-discovery.jar (required for SOAP mode)
* 9. commons-logging.jar (required for SOAP mode)
* 10. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 11. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 12. jaxrpc.jar (required for SOAP mode)
* 13. log4j.jar (required for SOAP mode)
* 14. mail.jar (required for SOAP mode)
* 15. saaj.jar (required for SOAP mode)
* 16. wsdl4j.jar (required for SOAP mode)
* 17. xalan.jar (required for SOAP mode)
* 18. xbean.jar (required for SOAP mode)
* 19. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms 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 additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport com.adobe.livecycle.output.client.*;
βimport java.util.*;
βimport java.io.File;
βimport java.io.FileInputStream;
βimport com.adobe.idp.Document;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class TransformPDF {
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_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 object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an OutputClient object
β OutputClient outClient = new OutputClient(myFactory);
β //Reference an interactive PDF document to transform
β FileInputStream fileInputStream = new FileInputStream("C:\\ΓΫΆΉΚΣΖ΅\Loan.pdf");
β Document inPDFDoc = new Document (fileInputStream);
β //Transform the PDF document to a non-interactive PDF document
β Document transformedDocument = outClient.transformPDF(
β inPDFDoc,
β TransformationFormat.PDF,
β null,
β null,
β null);
β //Save the non-interactive PDF document
β File myFile = new File("C:\\ΓΫΆΉΚΣΖ΅\NonInteractiveLoan.pdf");
β transformedDocument.copyToFile(myFile);
β }catch (Exception ee)
β {
β ee.printStackTrace();
β }
β }
β}