Posts tagged "PDF"

XFA-based PDF forms on Firefox 19

With the release of Firefox 19, Mozilla introduced a built-in PDF viewer. However, the XFA-based PDF forms do not open in the PDF viewer, by default. To open these forms using Firefox 19, you’d need to configure Firefox to open PDFs in Adobe Reader or Adobe Acrobat.

For more details on how to accomplish this, see the knowledge base article at

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 5.0/10 (2 votes cast)

Using LiveCycle to programmatically split the PDF documents – Part 1

- Khushwant Singh, Content and Community Lead @ Adobe

A discussion on Adobe forums indicates that a lot of LiveCycle users are trying to figure out how to programmatically split a PDF file. Adobe LiveCycle provides a simple method to programmatically split PDF documents using LiveCycle Assembler service. You can split PDF files using the bookmark tags or by page number.

To split the PDF documents, you require:

  • A DDX (For more information about DDX, see Adobe LiveCycle DDX reference guide)
  • Source documents
  • Access to the running instance of Adobe LiveCycle

You can write a custom DDX document suited to your requirements.  Some of the most commonly requested DDX are:

DDX for splitting PDF document using bookmarks

In the following sample DDXLiveCycle Assembler service generates a single document for each level 1 bookmark in the source document (AssemblerResultPDF.pdf in this example). The Assembler service generates a name for each document that is the concatenation of the following items:

  • A string specified by the prefix attribute
  • A 6-digit sequence number (This number could be used to re-create the original order of the pages after the document is disassembled.)
  • The bookmark title
  • The filename extension .pdf

<PDFsFromBookmarks prefix="stmt">
<PDF source="doc1.pdf"/>

DDX for splitting PDF document using page numbers

In this sample DDXLiveCycle Assembler service generates documents for the mentioned page number from the source document. The Assembler service generates a name for each document based on the result parameter specified in the DDX.

<?xml version="1.0" encoding="UTF-8"?>
<DDX xmlns="">
<PDF result="Final.pdf">
<PDF source="PDF1.pdf" pages="1"/>
<PDF result="Final2.pdf">
<PDF source="PDF1.pdf" pages="2"/>

DDX for splitting PDF document using the page range

In this sample DDXLiveCycle Assembler service generates documents for the mentioned range of the pages. The Assembler service generates a name for each document based on the result parameter specified in the DDX.

<?xml version="1.0" encoding="UTF-8"?>
<DDX xmlns="">
<PDF result="Final.pdf">
<PDF source="PDF1.pdf" pages="1-5"/>

DDX for splitting PDF documents using page range from different PDF documents and creating a single resultant PDF document

In the following sample DDXLiveCycle Assembler service extracts pages from multiple documents as per the range of pages mentioned in the DDX and generates a single output document

<?xml version="1.0" encoding="UTF-8"?>
<DDX xmlns="">
<PDF result="Final.pdf">
<PDF source="PDF1.pdf" pages="1-3"/>
<PDF source="PDF2.pdf" pages="4-5"/>

Sample program to split a PDF document
Let us write a simple Java program to split a PDF document into multiple documents.   To download the resources used in this sample program, click here.

Complete the following steps:

  1. Create a new file and add the following code  to the file
    <DDX xmlns="">
    <PDFsFromBookmarks prefix="Readme">
    <PDF source="AssemblerResultPDF.pdf"/>

    For this example, save the XML file as shell_disassemble.xml.
  2. Create a new Java project and add shell_disassemble.xml to the project.
  3. Add the following libraries to your project. These libraries are required to invoke assembler service in SOAP mode:
    • adobe-assembler-client.jar
    • adobe-livecycle-client.jar
    • adobe-usermanager-client.jar
    • adobe-utilities.jar
    • jbossall-client.jar (use a different JAR file if LiveCycle ES is not deployed on JBoss)
    • activation.jar
    • axis.jar
    • commons-codec-..jar
    • commons-collections-..jar
    • commons-discovery.jar
    • commons-logging.jar
    • dom-xml-apis-.jar
    • jaxen-.-beta-jar
    • jaxrpc.jar
    • log4j.jar
    • mail.jar
    • saaj.jar
    • wsdl4j.jar
    • xalan.jar
    • xbean.jar
    • xercesImpl.jar
  4. Create a new class named DisassemblePDFSOAP .
  5. Add the source PDF file to the project. I have used AssemblerResultPDF.pdf
  6. Add following code to the class:
    import com.adobe.livecycle.assembler.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 DisassemblePDFSOAP
    public static void main (String args[]) {
    Document outDoc = null;
    //Set connection properties required to invoke LiveCycle ES2
    Properties connectionProps = new Properties();
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, “″);
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, “JBoss”);
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, “administrator”);
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, “password”);//Create a ServiceClientFactory instance
    ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);//Create an AssemblerServiceClient object
    AssemblerServiceClient assemblerClient = new AssemblerServiceClient(myFactory);FileInputStream myDDXFile = new FileInputStream(“E:\\workspace\\disassemble\\src\\shell_disassemble.xml”);
    //Create a Document object based on the DDX file
    Document myDDX = new Document(myDDXFile);//Create a Map object to store PDF source documents
    Map inputs = new HashMap();FileInputStream mySourceMap = new FileInputStream(“E:\\workspace\\backup\\disassemble\\src\\AssemblerResultPDF.pdf”);//Create a Document object based on the map.pdf source file
    Document myPDFSource = new Document(mySourceMap);//Place two entries into the Map object
    inputs.put(“AssemblerResultPDF.pdf”,myPDFSource);//Create an AssemblerOptionsSpec object
    AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec();
    assemblerSpec.setFailOnError(false);//Submit the job to the Assembler service
    AssemblerResult jobResult = assemblerClient.invokeDDX(myDDX,inputs,assemblerSpec);
    java.util.Map allDocs = jobResult.getDocuments();

    //Retrieve the result PDF documents from the Map object

    int index = 0;

    //Iterate through the map object to retrieve the result PDF document
    for (Iterator i = allDocs.entrySet().iterator(); i.hasNext();) {
    // Retrieve the Map object’s value

    Map.Entry e = (Map.Entry);
    if (index == 0)
    Object o = e.getValue();

    //Cast the Object to a Document
    //and save to a file
    outDoc = (Document)o;
    File myOutFile = new File(“E:\\disassemble\\SplitPDF”+index +”.pdf”);
    if (index > 0)
    System.out.println(“The PDF document was disassembled into “+index+” PDF documents.”);
    System.out.println(“The PDF document was not disassembled.”);

    }catch (Exception e) {
    System.out.println(“Error OCCURRED: “+e.getMessage());

  7. Modify the locations mentioned in the sample code according to the file paths in your machine
  8. Run the code.
  9. The code splits the file into multiple PDF documents based on the bookmarks or the page numbers specified in the DDX.

This is first blog in the series of the blogs about programmatically splitting the PDF document. In this blog I have shared sample code to split PDF document using bookmarks. In the follow-up blogs, I will include sample code to split PDF documents using:

  • Page numbers
  • Page range
  • Pages from different PDF documents and generate a single output document
VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 9.2/10 (5 votes cast)