For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
Manipulating PDF forms in ColdFusion / 

Extracting data from a PDF form submission

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Data extraction differs based on how the PDF form is submitted. ColdFusion supports two types of PDF form submission: HTTP post, which submits the form data, but not the form itself, and PDF, which submits the entire PDF file.
One use for PDF submission is for archival purpose: because the form is submitted with the data, you can write the output to a file. HTTP post submissions process faster because only the field data is transmitted, which is useful for updating a database or manipulating specific data collected from the form, but you cannot write an HTTP post submission directly to a file.

Note: Although forms created in LiveCycle Designer allow several types of submission, including XDP and XML, ColdFusion can extract data from HTTP post and PDF submissions only.

In LiveCycle Designer, the XML code for an HTTP post submission looks like the following example:

<submit format="formdata" target="http://localhost:8500/pdfforms/pdfreceiver.cfm" textEncoding="UTF-8"/>

In LiveCycle Designer, the XML code for a PDF submission looks like the following example:

<submit format="pdf" target="http://localhost:8500/pdfforms/pdfreceiver.cfm" textEncoding="UTF-16" xdpContent="pdf datasets xfdf"/>

Note: Acrobat forms are submitted in binary format, not XML format.

Extracting data from a PDF submission

Use the following code to extract data from a PDF submission and write it to a structure called fields:

<!--- The following code reads the submitted PDF file and generates a result structure called fields. --->
<cfpdfform source="#PDF.content#" action="read" result="fields"/>

Use the cfdump tag to display the data structure, as follows:

<cfdump var="#fields#">

Note: When you extract data from a PDF submission, always specify "#PDF.content#" as the source.

You can set the form fields to a variable, as the following example shows:

<cfset empForm="#fields.form1#">

Use the populate action of the cfpdfform tag to write the output to a file. Specify "#PDF.content#" as the source. In the following example, the unique filename is generated from a field on the PDF form:

<cfpdfform action="populate" source="#PDF.content#"
destination="timesheets\#empForm.txtsheet#.pdf" overwrite="yes"/>

Writing LiveCycle form output to an XDP file

For Acrobat forms, you can write the output to a PDF file only. For LiveCycle forms, you have the option to write the output to an XDP file. The filename extension determines the file format: to save the output in XDP format, simply use an XDP extension in the destination filename, as the following example shows:

<cfpdfform action="populate" source="#PDF.content#"
destination="timesheets\#empForm.txtsheet#.xdp" overwrite="yes"/>

An XDP file is an XML representation of a PDF file. In LiveCycle Designer, an XDP file contains the structure, data, annotations, and other relevant data to LiveCycle forms, which renders the form at run time.
ColdFusion XDP files contain the XDP XML code and the PDF image. Therefore, the file size is larger than a PDF file. Only write PDF forms to XDP files if you must incorporate them into the LiveCycle Designer workflow on a LiveCycle server.

Writing PDF output to an XML file

ColdFusion lets you extract data from a PDF form and write the output to an XML data file. To do so, you must save the form output as a PDF file. (The cfpdfform tag source must always be a PDF file.)
To write the output of a PDF file to an XML file, use the read action of the cfpdfform tag, as the following example shows:

<cfpdfform action="read" source="#empForm.txtsheet#.pdf"
XMLdata="timesheets\#empForm.txtsheet#.xml"/>

To save disk space, you can delete the PDF file and maintain the XML data file. As long as you keep the blank PDF form used as the template, you can use the populate action to regenerate the PDF file. For more information on populating forms, see Populating a PDF form with XML data.

Extracting data from an HTTP post submission

For an HTTP post submission, use the cfdump tag with the form name as the variable to display the data structure, as follows:

<cfdump var="#FORM.form1#">

Note: When you extract data from an HTTP post submission, always specify the form name as the source. For example, specify "#FORM.form1#" for a form generated from a standard template in LiveCycle.

Notice that the structure is not necessarily the same as the structure of the PDF file used as the template (before submission). For example, the structure of a form before submission could look like the following example:

struct

 

form1

struct

txtDeptName

empty string

txtEMail

empty string

txtEmpID

empty string

txtFirstName

empty string

txtLastName

empty string

txtPhoneNum

empty string

After submission by using HTTP post, the resulting structure would look like the following example:

struct

 

FORM1

struct

SUBFORM

struct

HEADER

struct

HTTPSUBMITBUTTON1

empty string

TXTDEPTNAME

Sales

TXTFIRSTNAME

Carolynn

TXTLASTNAME

Peterson

TXTPHONENUM

(617) 872-9178

TXTEMPID

1

TXTEMAIL

carolynp@company

 

Note: When data extraction using the cfpdfform tag results in more than one page, instead of returning one structure, the extraction returns one structure per page.

The difference in structure reflects internal rules applied by Acrobat for the HTTP post submission.
To extract the data from the HTTP post submission and update a database with the information, for example, map the database columns to the form fields, as the following code shows:

<cfquery name="updateEmpInfo" datasource="cfdocexamples">
UPDATE EMPLOYEES
SET FIRSTNAME = "#FORM1.SUBFORM.HEADER.TXTFIRSTNAME#",
LASTNAME = "#FORM1.SUBFORM.HEADER.TXTLASTNAME#",
DEPARTMENT = "#FORM1.SUBFORM.HEADER.TXTDEPTNAME#",
IM_ID = "#FORM1.SUBFORM.TXTEMAIL#",
PHONE = "#FORM1.SUBFORM.HEADER.TXTPHONENUM#"
WHERE EMP_ID = <cfqueryparam value="#FORM1.SUBFORM.TXTEMPID#">
</cfquery>

You can set a variable to create a shortcut to the field names, as the following code shows:

<cfset fields=#form1.subform.header#>

Use the cfoutput tag to display the form data:

<h3>Employee Information</h3>
<cfoutput>
<table>
<tr>
<td>Name:</td>
<td>#fields.txtfirstname# #fields.txtlastname#</td>
</tr>
<tr>
<td>Department:</td>
<td>#fields.txtdeptname#</td>
</tr>
<tr>
<td>E-Mail:</td>
<td>#fields.txtemail#</td>
<tr>
<td>Phone:</td>
<td>#fields.txtphonenum#</td>
</tr>
<table>
</cfoutput>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices