Posts in Category "Tutorials"

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"/>
</PDFsFromBookmarks>

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="http://ns.adobe.com/DDX/1.0/">
<PDF result="Final.pdf">
<PDF source="PDF1.pdf" pages="1"/>
</PDF>
<PDF result="Final2.pdf">
<PDF source="PDF1.pdf" pages="2"/>
</PDF>
</DDX>

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="http://ns.adobe.com/DDX/1.0/">
<PDF result="Final.pdf">
<PDF source="PDF1.pdf" pages="1-5"/>
</PDF>
</DDX>

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="http://ns.adobe.com/DDX/1.0/">
<PDF result="Final.pdf">
<PDF source="PDF1.pdf" pages="1-3"/>
<PDF source="PDF2.pdf" pages="4-5"/>
</PDF>
</DDX>

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="http://ns.adobe.com/DDX/1.0/">
    <PDFsFromBookmarks prefix="Readme">
    <PDF source="AssemblerResultPDF.pdf"/>
    </PDFsFromBookmarks>
    </DDX>

    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 java.io.InputStream;
    import java.io.*;
    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;
    try{
    //Set connection properties required to invoke LiveCycle ES2
    Properties connectionProps = new Properties();
    connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, “http://10.40.18.95:8080″);
    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 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)i.next();
    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”);
    outDoc.copyToFile(myOutFile);
    }
    index++;
    }
    if (index > 0)
    System.out.println(“The PDF document was disassembled into “+index+” PDF documents.”);
    else
    System.out.println(“The PDF document was not disassembled.”);

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

  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)

Creating web applications using HTML5/JavaScript Remoting Client SDK with LiveCycle Data Services

- Harpreet Singh, Technical Support @ Adobe

LiveCycle Data Services 4.6 provides a HTML5/JavaScript library that lets you develop client applications that call remoting destinations in Data Services using plain HTML and JavaScript with no Adobe Flash involved.

You can use the JavaScript APIs that do not require compilation against services-config.xml. Remoting only needs destination-to-channel mapping, and the channel information (URL, ID) from services-config.xml. Therefore, instead of compiling against the services-config.xml, you create your own ChannelSet, and assign a component (RemoteObject) before using the component. Alternatively, if your browser supports the HTML5 WebSockets, you can use a WebSocket channel, instead of a RTMP channel in Flash, for real-time communication.

  1. Set up the channel(s).
    var channel = new flex.client.channels.Channel("my-amf","http://localhost:8400/RemotingHtmlLcdsApp/messagebroker/amf");
    var amfChannel = new flex.client.channels.Channel("my-nio-amf","http://localhost:2080/nioamf","flex.client.channels.Channel.HttpMode.REGULAR");
    var wsChannel = new flex.client.channels.Channel("my-nio-amf-websocket","ws://localhost:2080/nioamfwebsocket");
  2. Create a channel set.
    var channelSet = new flex.client.channels.ChannelSet([ channel,amfChannel ]);
  3. Create and initialize a RemoteObject with channelSet and destinationId.
    var remoteObject = new flex.client.rpc.remoting.RemoteObject("EchoService");
    remoteObject.setChannelSet(channelSet);
  4. Add the result and fault handlers for the remoteObject.
    remoteObject.addEventListener(flex.client.rpc.events.ResultEvent.RESULT, function(resultEvent) {
    result = resultEvent.getResult();
    alert(result);
    });
    remoteObject.addEventListener(flex.client.rpc.events.FaultEvent.FAULT, function(faultEvent) {
    var fault = faultEvent.getFaultString();
    alert(fault);
    });
  5. Make the remoting call and call the disconnect on remoteObject.
    remoteObject.invoke("echo");
    remoteObject.disconnect();

Download the sample code from here. Access the JavaScript reference here.

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

Exciting new articles on using Managed Review & Approval Solution Accelerator 9.5

Here are two more great posts from Alexandra Phillips on Managed Review & Approval Solution Accelerator 9.5. You will certainly find these post useful if you are implementing Managed Review & Approval as Alexandra shows you how to display a list of participants in the review emails and how to retrieve a RSS XML file to list all the comments made by reviewers for a document!

Check out the following articles:

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

Exciting new tutorial using LiveCycle Designer 9.5

Twin Technologies continues to share their knowledge with the Adobe LiveCycle community. Jack Freudenheim and Benjamin P. Lyons show you how to prepopulate drop-down lists in a dynamic PDF form using a back-end datasource in a tutorial. Check out this very informative tutorial here.

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

Rebranding the ICR email templates

This blog post is part of the series on customizing the Adobe Integrated Content Review solution.

***

Integrated Content Review solution sends out system-generated email notifications to team members and participants, for various events. Templates used for these email can be customized as per your branding requirements.

This customization scenario involves the following top-level steps:

  1. Locating the email template files
  2. Customizing the images in the email template files
  3. Customizing the content in the email template files
  4. Knowledge of all the available variables to customize the content in Step 3

For detailed information about these steps, refer to this (PDF) document.

See also:
This matrix of system-generated email notifications sent to participants.
This page, to know more about ICR solution.

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

Writing pre- and post-stage hooks for Integrated Content Review solution

The Review, Commenting, and Approval building block, part of the Integrated Content Review solution, allows you to inject said functionality or custom Document Services processes at any point in your solutions workflow. You can add functionality or custom processes prior to or after staging, called Pre-stage and Post-stage hooks respectively. See Writing Pre- and Post-Stage Hooks for more information and a quickstart to help you get started.

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

Hot off the press! Adding tabs to Adobe LiveCycle Workspace ES2

In LiveCycle Workspace ES2 (version 9.0.0.2), tabs are available for you to start new processes, view tasks that are assigned to you, and track tasks and processes. What if you wanted to add your own tab to enhance it? Check out a new article by Nithiyanandam Dharmadass that describes how to add navigation tabs to Workspace here.

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

Tutorial to use the Execute Script service in Adobe LiveCycle Workbench ES2

Would you like to learn how to use the Execute Script service to manipulate XML using LiveCycle Workbench ES2? Here is a tutorial provided by one of our Adobe partners, Twin Technologies!

Check out the most excellent tutorial from Deke Smith at here.

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

Access custom Microsoft Office properties using LiveCycle services

Marcel van Espen, over at the Dr Flex and Dr LiveCycle blog, explains how you can create a LiveCycle process to access custom Office properties. His blog post also includes a useful example.

“Within LiveCycle Workbench ES, one of the services in the common category that you can use is ‘Export XMP’. This service will extract all the available metadata from a PDF document. If you have converted a MS-Office document to a PDF document, you will be surprised what metadata is also converted. All these properties now become accessible.”

Read the complete post here.

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

Tutorial to bind dynamic fields to a data schema

Do you want to learn how to bind dynamic forms fields to schema in Adobe LiveCycle Designer ES2? Here is a tutorial provided by one of our Adobe partners, Twin Technologies! The article is posted on Adobe DevNet here.

Enjoy!

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