ColdFusion 9.0 Resources |
cfpdfformDescriptionManipulates existing forms created in Adobe® Acrobat® and Adobe® LiveCycle® Designer. The following list describes some of the tasks you can perform with the cfpdfform tag:
Syntaxpopulate <cfpdfform required action = "populate" source = "PDF file pathname|byte array" optional XMLdata = "XML object|XML string|XML data filename| URL that returns XML data" destination = "output file pathname" overwrite = "yes|no"/ fdf = "true|false> <!---New attribute that populates data in FDF format instead of XML with subforms and params---> fdfdata = "file name to be imported" <!--- New attribute populates data in FDF format from the AcroForm---> read <cfpdfform required action = "read" source = "pathname|byte array" at least one of the following: XMLdata = "variable name for XML data" result = "structure containing form field values" optional overwrite = "yes|no"/> fdfdata = "filename to be exported to" Note: You can specify this tag’s attributes
in an attributeCollection attribute whose value
is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
See alsocfdocument, cfdocumentsection, cfform, cfinput, cfpdf, cfpdfformparam, cfpdfparam, cfpdfsubformcfprint, IsPDFFile, IsPDFObject, Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications Attributes
UsageColdFusion supports two types of interactive forms: forms created in Adobe Acrobat 6.0 or earlier, and forms created in Adobe LiveCycle. In Adobe Acrobat Professional and Standard 7.0, Adobe introduced Adobe® LiveCycle® Designer for creating PDF forms. ColdFusion supports forms created in LiveCycle Designer 7.0 and later. Forms created in Acrobat have a flat structure: a list of fields at the same level. Forms created in LiveCycle Designer are hierarchical, often composed of nested subforms. To map the data to the form field, you use cfpdfsubform tags to recreate the structure of the form in ColdFusion. For examples, see the Usage section of the cfpdfsubform tag, and “ Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications.
Extracting data from a PDF submissionUse 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 code 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"/> Extracting data from an HTTP post submissionAn HTTP post submission transmits the data from the PDF form, but not the form itself. You can extract data from the PDF form fields, but you cannot write the output directly to a file. To extract the data and update a database, for example, you must map the fields in the database to the structure and HTTP post data exactly. Note: The
structure of the HTTP post data (after submission) is not the same
as the structure of the PDF form (before data submission). For examples
of both, see Manipulating
PDF Forms in ColdFusion in the Developing ColdFusion Applications.
To determine the structure of the HTTP post data, 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 template
in LiveCycle Designer. When data extraction that uses the cfpdfform tag
results in more than one page, instead of returning one structure, ColdFusion
returns one structure per page.
Embedding PDF forms within a PDF documentYou can use the cfpdfform tag inside the cfdocument tag to embed an existing interactive PDF form within a PDF document. Use at least one cfdocumentsection tag with the cfpdfform tag, but do not place the cfpdfform tag within the cfdocumentsection tag. For more information about embedding PDF forms, see Manipulating PDF Forms in ColdFusion in the Developing ColdFusion Applications. Flattening forms created in AcrobatYou use the cfpdf tag to flatten forms created in Acrobat. ColdFusion does not support flattening forms created in LiveCycle. For more information, see Assembling PDF Documents in the Developing ColdFusion Applications. Printing formsUse the cfprint tag to print forms created in Acrobat. Markups, such as sticky notes, comments, and editorial revisions, are not printed with the form. You cannot use the cfprint tag to print forms created in LiveCycle Designer. Exporting PDF Forms in FDFIn ColdFusion 9, you can now export PDF forms in FDF format using the read action. The following example shows how you can export a PDF form in FDF format: <cfpdfform source= "acroform_export.pdf" action="read" fdfdata="abc.fdf" > </cfpdfform> ExampleThe following example shows how to embed an interactive PDF form in a PDF document created with the cfdocument tag: <!--- The following code extracts data from the cfdocexamples database based on a username entered in a login form. ---> <cfquery name="getEmpInfo" datasource="cfdocexamples"> SELECT * FROM EMPLOYEES WHERE EMAIL = <cfqueryparam value="#form.username#"> </cfquery> <!--- The following code creates a PDF document with headers and footers. ---> <cfdocument format="pdf"> <cfdocumentitem type="header"> <font size="-1" align="center"><i>Nondisclosure Agreement</i></font> </cfdocumentitem> <cfdocumentitem type="footer"> <font size="-1"><i>Page <cfoutput>#cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput></i></font> </cfdocumentitem> <!--- The following code creates the first section in the PDF document. ---> <cfdocumentsection> <h3>Employee Nondisclosure Agreement</h3> <p>Please verify the information in the enclosed form. Make any of the necessary changes in the online form and click the <b>Print</b> button. Sign and date the last page. Staple the pages together and return the completed form to your manager.</p> </cfdocumentsection> <!--- The following code embeds an interactive PDF form within the PDF document with fields populated by the database query. The cfpdpfform tag automatically creates a section in the PDF document. Do not embed the cfpdfform within cfdocumentsection tags. ---> <cfpdfform action="populate" source="c:\forms\embed.pdf"> <cfpdfsubform name="form1"> <cfpdfformparam name="txtEmpName" value="#getEmpInfo.FIRSTNAME# #getEmpInfo.LASTNAME#"> <cfpdfformparam name="txtDeptName" value="#getEmpInfo.DEPARTMENT#"> <cfpdfformparam name="txtEmail" value="#getEmpInfo.IM_ID#"> <cfpdfformparam name="txtPhoneNum" value="#getEmpInfo.PHONE#"> <cfpdfformparam name="txtManagerName" value="Randy Nielsen"> </cfpdfsubform> </cfpdfform> <!--- The following code creates the last document section. Page numbering resumes in this section. ---> <cfdocumentsection> <p>I, <cfoutput>#getEmpInfo.FIRSTNAME# #getEmpInfo.LASTNAME#</cfoutput>, hereby attest that the information in this document is accurate and complete.</p> <br/><br/> <table border="0" cellpadding="20"> <tr><td width="300"> <hr /> <p><i>Signature</i></p></td> <td width="150"><hr /> <p><i>Today's Date</i></p></td></tr> </cfdocumentsection> </cfdocument> |