About PDF forms

Adobe ColdFusion lets you incorporate interactive PDF forms in your application. You can extract data submitted from the PDF forms, populate form fields from an XML data file or a database, and embed PDF forms in PDF documents created in ColdFusion.

ColdFusion supports interactive forms created with Adobe Acrobat forms and with LiveCycle. In Adobe Acrobat 6.0 or earlier, you can create interactive Acroforms. Using Adobe LiveCycle Designer, which is provided with Adobe Acrobat Professional 7.0 and later, you can generate interactive forms.

The type of form is significant because it affects how you manipulate the data in ColdFusion. For example, you cannot use an XML data file generated from a form created in Acrobat to populate a form created in LiveCycle, or the reverse, because the XML file formats differ between the two types of forms.

Forms created in Acrobat use the XML Forms Data Format (XFDF) file format. Forms created in LiveCycle use the XML Forms Architecture (XFA) format introduced in Acrobat and Adobe Reader 6. For examples, see Populating a PDF form with XML data. The file format also affects how you prefill fields in a form from a data source, because you map the data structure as well as the field names. For examples, see Prefilling PDF form fields.

The use of JavaScript also differs based on the context. The JavaScript Object Model in a PDF file differs from the HTML JavaScript Object Model. Consequently, scripts written in HTML JavaScript do not apply to PDF files. Also, JavaScript differs between forms created in Acrobat and those forms created in LiveCycle: scripts written in one format do not work with other.

ColdFusion 9 introduced several tags for manipulating PDF forms:

Tag

Description

cfpdfform

Reads data from a form and writes it to a file or populates a form with data from a data source.

cfpdfformparam

A child tag of the cfpdfform tag or the cfpdfsubform tag; populates individual fields in PDF forms.

cfpdfsubform

A child tag of the cfpdfform tag; creates the hierarchy of the PDF form so that form fields are filled properly. The cfpdfsubform tag contains one or more cfpdpformparam tags.

The following table describes a few of the tasks that you can perform with PDF forms:

Task

Tags and actions

Populate a PDF form with XML data

populate action of the cfpdf tag

Prefill individual fields in a PDF form with data from a data source

populate action of the cfpdfform tag with the cfpdfsubform and cfpdfparam tags

Determine the structure of a PDF form

read action of the cfpdfform tag with the cfdump tag

Embed an interactive PDF form within a PDF document

populate action of the cfpdfform tag within the cfdocument tag.

Note: The cfpdfform tag must be at the same level as the cfdocumentsection tags, not contained within them.

Write a PDF form directly to the browser

populate action of the cfpdfform tag with the destination attribute not specified

Write PDF form output to an XML file

read action of the cfpdfform tag

Print a PDF form from ColdFusion

cfprint tag

Extract data from a PDF form submission

source="#PDF.Content#" for the read action of the cfpdfform tag

Write data extracted from a PDF form submission to a PDF file

source="#PDF.Content#" for the populate action of the cfpdfform tag, and the destination attribute

Write data in a form generated in LiveCycle to an XDP file

source="#PDF.Content#" for the populate action of the cfpdfform tag, and an XDP extension for the output file

Extract data from an HTTP post submission

cfdump tag determines the structure of the form data; map the form fields to the output fields

Flatten forms generated in Acrobat (not used forms generated in LiveCycle)

cfpdf

For more information, see Flattening forms created in Acrobat.

Merge forms generated in Acrobat or LiveCycle with other PDF documents

cfpdf action="merge"

For more information, see Merging PDF documents.