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.
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"/>
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#">
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"/>