
916
DEVELOPING
COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Las
t
upda
te
d 8/5/2010
When you populate a form with an XML data file, ensure that the XML data is in the appropriate format. The format
of the XML data file differs based on whether it was generated from Acrobat or LiveCycle. Acrobat generates an XML
Forms Data Format (XFDF) file format. The following example shows the XFDF format:
<?xml version="1.0" encoding="UTF-8"?>
- <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
- <fields>
- <field name="textname">
<value>textvalue</value>
</field>
- <field name="textname1">
<value>textvalue1</value>
</field>
</fields>
</xfdf>
Forms created in LiveCycle require an XML Forms Architecture (XFA) format. The following example shows an XFA
format:
<?xml version="1.0" encoding="UTF-8"?>
- <xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
- <form1>
<SSN>354325426</SSN>
<fname>coldfusion</fname>
<num>354325426.00</num>
- <Subform1>
<SSN />
</Subform1>
</form1>
</xfa>
Prefilling PDF form fields
ColdFusion lets you prefill individual form fields with data extracted from a data source. For example, you can run a
query to extract returning customer information from a data source based on a user name and password and populate
the related fields in an order form. The customer can complete the rest of the fields in the form and submit it for
processing. To do so, map the field names and the data structure of the PDF form to the fields in the data source.
To determine the structure of the PDF form, use the read action of the
cfpdfform
tag, as the following example shows:
<cfpdfform source="c:\forms\timesheet.pdf" result="resultStruct" action="read"/>
Then use the
cfdump
tag to display the structure:
<cfdump var="#resultStruct#">
The result structure for a form created in Acrobat form could look something like the following example:
To prefill the fields in ColdFusion, you add a
cfpdfformparam
tag for each of the fields directly under the
cfpdfform
tag:
struct
firstName
[empty string]
lastName
[empty string]
department
[empty string]
...
...