Accessibility
Allen Levine

Allen Levine

blxonline.com

Created:
5 February 2007
User Level:
Intermediate
Products:
Livecycle

Leveraging Adobe LiveCycle Designer with ColdFusion

Adobe LiveCycle Designer makes it easy to create interactive forms that combine high-fidelity presentation of PDF and HTML documents with powerful XML data handling. Forms created with LiveCycle Designer can also be used to capture and submit user entered data in a variety of ways.

Typically, PDF form data is submitted and processed by Adobe LiveCycle Forms. Formerly called Form Server, LiveCycle Forms is a J2EE server-based application that allows organizations to build applications that leverage PDF technology. The primary uses for LiveCycle Forms is for rendering PDF documents with or without merging field data and for capturing form data submitted over the Internet.

This article focuses on how to develop applications that leverage LiveCycle Designer for the form submission process via ColdFusion.

Requirements

To make the most of this article, you need to install the following software and files and read the related article:

LiveCycle Designer

ColdFusion MX 7.0.2

Sample files:

Related articles

I have written several articles about using ColdFusion with LiveCycle forms to perform a variety of functions including pre-population of PDF Forms, and applying Reader Extensions. These articles were written with the common theme of leveraging Adobe LiveCycle products with limited or no knowledge or use of Java:

Background

Adobe LiveCycle Designer makes it easy to create interactive forms that combine high-fidelity presentation of PDF and HTML documents with powerful XML data handling. With LiveCycle Designer, you can streamline form-driven business processes within and beyond your enterprise.

LiveCycle software easily integrates into enterprise infrastructures through Java application programming interfaces (APIs) and web services protocols. You can deploy LiveCycle software on IBM WebSphere, BEA WebLogic, and JBoss application servers. By integrating forms with core business systems using the powerful XML data transfer capabilities in LiveCycle Designer, you can submit forms and capture data directly to core business applications, improving data accuracy and streamlining form processing. Support for XML schemas means that any electronic form created with LiveCycle Designer can be easily integrated with existing business applications. Using the drag-and-drop interface, you create links between form fields and existing XML schemas without complicated programming, helping to reduce the high cost of developing XML-based applications.

Our organization uses ColdFusion for our web applications. However, we do not have any Java experience. Because LiveCycle Forms is a J2EE application, we wanted to integrate it while limiting or even eliminating the need to know any Java.

The solution

Forms created using Live Cycle Designer provide the ability to submit collected data in a variety of ways. When you create a button and set its Control Type to Submit, the Submit tab appears in the Object palette. It presents a number of options specific to formatting buttons that submit data (see Figure 1).

Submit tab in LiveCycle Designer

Figure 1. Submit tab in LiveCycle Designer

Submit format options

LiveCycle Designer supports four submit formats:

  • XML Data Package (XDP) submits a package in the file format created by LiveCycle Designer. Choose this format if the form initiates server-side processing, or to submit the form design, the form data, annotations, and all other relevant information needed for LiveCycle Form to render the form subsequently at runtime.
  • PDF submits a package containing an embedded PDF file. Choose this format if the form contains a signature field, or if a copy of the form together with its data needs to be saved by LiveCycle Form or submitted to some other kind of target server. Do not choose this option if the form initiates server-side processing, if LiveCycle Form will be used to render HTML or dynamic forms at runtime, or if the form is a PDF form that will be filled in Adobe Reader without the use of LiveCycle Reader Extensions.
  • XML Data submits an XML data stream, which allows for the hierarchical representation of data and can be parsed by any generic XML parser. Choose this format if the server that communicates with the runtime user application program must receive an XML data steam.
  • URL-Encoded Data submits a text stream to the specified Uniform Resource Locator (URL) using the POST method. The text stream can be parsed by an FTP server, mail server, web server, or CGI script that processes HTML forms. To use this method, users must open the form in Adobe Reader 6.0 or a web browser unless the URL specifies the mailto protocol.

Note: If you are interested in using the URL-Encoded Data format, contact me for another component I have written for this format specifically. There are several roadblocks that you will encounter if you try to parse the data in ColdFusion. Fortunately I have already done the work for you. For this sample we will be using the XML Data option.

Sample PDF

This sample PDF contains two buttons (see Figure 2):

Sample PDF form with two buttons.

Figure 2. Sample PDF form with two buttons

We will be using the Submit via Internet button for this example. Once the data fields have been completed and the user clicks the button, the data represented in XML will be submitted to the URL. The Submit via Email button is also a very useful feature to allow users that may be sensitive to submitting data to a hidden URL. In my environment I have set up a simple listener that checks an e-mail account and automatically imports XML data submitted via this method. This feature is also useful to see the actual XML file that will be posted.

Sample file Upload.cfm

The sample file Upload.cfm shows one method to capture the data that has been submitted. When you click the button, an HTTP post is instantiated and the content is an XML representation of the data.

Sample data

<?xml version="1.0" encoding="UTF-8" ?> 
<mainform>
    <page_1>
        <txtName>Sample Name</txtName> 
        <txtCompany>Sample Company</txtCompany> 
        <txtAddress>124 Broadway</txtAddress> 
        <txtCity>Somewhere</txtCity> 
        <txtState>AZ</txtState> 
        <txtZip>04587</txtZip> 
        <txtPhone>111-222-3333</txtPhone> 
        <txtFax>222-333-4444</txtFax> 
    </page_1>
</mainform>

Now that the data is posted, all you need to do is simply parse the XML to your liking.

Snippet

<!--- Capture The Actual XML Data To A Variable --->
<cfset x = GetHttpRequestData()>
<cfset strXML = '#toString(x.content)#'>

<!--- Now We Parse The Actual XML --->
    <cfset tsUpload = #Now()#>
    <cfset parsedXML = xmlParse(strXML)>
    <cfset isXML = isXmlDoc(parsedXML)>

    <!--- Check For Well Formatted XML Doc --->
    <cfif isXML EQ 'Yes'>
    <!--- Get the root element --->
    <cfset theRoot = parsedXML.XmlRoot>

    <!--- Test to ensure that element exists and save value to variable.  -->
    <cfif StructKeyExists(theRoot.XmlChildren[1],"txtName") EQ 'YES'>
        <cfset txtName = theRoot.XmlChildren[1]["txtName"].XmlText>
    <cfelse>
        <cfset txtName = "Element Does Not Exist">
    </cfif>

This is a very basic sample. Obviously there are many different ways to reference actually elements.

That's it!

You have now created a PDF form and provided the functionality to submit the data over the Internet. All that is left now is to explore the many possibilities to leverage this technology.

Where to go from here

I have been extremely successful creating many complex PDF forms and submitting the data over the Internet. These processes have allowed us to automate many different areas within our organization. I found out quickly that leveraging the technology is easy and offers endless possibilities. The largest contributing factor to our success has been implementing Adobe LiveCycle Forms in many areas of our organization. In case you are interested, check out the article BLX's component for Adobe LiveCycle Forms (PDF, 546K) regarding Adobe LiveCycle Forms as it relates to business processing.

Download the sample ZIP file at the beginning of this article. It includes the following sample files:

  • Sample.pdf
  • Upload.cfm

About the author

Allen Levine is the webmaster for Business Loan Express, a non-bank small business and commercial lender. Allen has been developing web applications for 15 years and has been developing in ColdFusion since 1997. He can be reached at alevine@blx.net.