You can use the cfpdfform tag inside the cfdocument tag to embed an existing interactive PDF form in a PDF document. This technique is useful to include additional information with a standard interactive form. For example, a company could have a generic PDF form for maintaining employee information. You could reuse this form in different contexts to ensure that the employee information is current.
To create the static PDF pages, use the cfdocument tag and cfdocumentsection tags. Then use the cfpdfform tag in the cfdocument tag to create an interactive form in the PDF document. When the user updates the form and prints or submits it, all of the pages in the document, including the static PDF pages, are printed or submitted with the form.

Note: You can embed only one interactive form in a PDF document; therefore, include only one cfpdfform tag in a cfdocument tag. However, each cfpdfform tag can include multiple cfpdfsubform tags and cfpdfformparam tags.

Use at least one cfdocumentsection tag with the cfpdfform tag, but do not place the cfpdfform tag within the cfdocumentsection tag. Instead, insure that the cfpdfform and cfdocumentsection tags are at the same level, the following example shows:

<cfdocument format="pdf">
<cfdocumentitem type="header">
<font size="+1">This is the Header</font>
</cfdocumentitem>
<cfdocumentitem type="footer">
<font size="+1">This is the Footer</font>
</cfdocumentitem>

<cfdocumentsection>
<p>This is the first document section.</p>
</cfdocumentsection>

<cfpdfform source="c:\forms\embed.pdf" action="populate">
<cfpdfsubform name="form1">
<cfpdfformparam name="txtManagerName" value="Janis Joplin">
<cfpdfformparam name="txtDepartment" value="Sales">
</cfpdfsubform>
</cfpdfform>

<cfdocumentsection>
<p>This is another section</p>
</cfdocumentsection>
</cfdocument>

The contents of the cfpdfform tag start on a new page. Any text or code directly after the cfdocument tag and before the cfpdfform tag applies to the document sections but not to the interactive PDF form in the cfpdfform tag.
The headers and footers that are part of the embedded PDF form do not apply to the rest of the PDF document, and the headers and footers that are defined in the cfdocument tag do not apply to the interactive form. However, header and footer information defined in the cfdocumentitem tags resumes in the sections that follow the embedded form and account for the pages in the embedded form.

Note: The read action of the cfpdfform tag is not valid when you embed a PDF form. Also, you cannot specify a destination in the cfpdfform tag. However, you can specify a filename in the cfdocument tag to write the PDF document with the PDF form to an output file. If you do not specify a filename, ColdFusion displays the PDF form in the context of the PDF document in the browser.

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