Adobe ColdFusion 8

cfpdfparam

Description

Provides additional information for the cfpdf tag. The cfpdfparam tag applies only to the merge action of the cfpdf tag and is always a child tag of the cfpdf tag.

History

ColdFusion 8: Added this tag.

Category

Forms tags

Syntax

<cfpdf action = "merge" ..>
    <cfpdfparam
    pages = "page number|page range|comma-separated page numbers"
    password = "user or owner password"
    source = "absolute or relative pathname to a PDF file|PDF document variable|
        cfdocument variable">
</cfpdf>

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 also

cfdocument, cfdocumentsection, cfpdf, Usagecfpdfform, Usagecfpdfformparam, cfpdfparam, cfpdfsubform, cfprint, IsPDFFile, IsPDFObject

Attributes

Attribute

Req/Opt

Default

Description

pages

Optional

 

Page or pages of the PDF source file to merge. You can specify a range of pages, for example, "1-5 ", or a comma-separated list of pages, for example, "1-5,9-10,18".

password

Optional

 

User or owner password, if the source PDF file is password-protected.

source

Required

 

Source PDF file to merge. You can specify a PDF variable, a cfdocument variable, or the pathname to a file.

Usage

Use the cfpdfparam tag to merge several PDF documents into one file. The cfpdfparam tag lets you specify the order of source files explicitly. You can use this tag to merge pages from multiple PDF document source files in different locations.

The following code creates a single PDF document called combined.pdf that contains pages 1-3 and page 5 of the file abc.pdf, followed by all of the pages in xyz.pdf, a file in memory with the variable name myPDFvariable, and lastly pages 10-90 from the file abc.pdf. The password attribute applies only if the source file is password-protected:

<cfpdf action="merge" destination="combined.pdf" overwrite="yes">
    <cfpdfparam source="c:\abc.pdf" pages="1-3,5" password="adobe">
    <cfpdfparam source="c:\new\xyz.pdf">
    <cfpdfparam source="myPDFvariable">
    <cfpdfparam source="abc.pdf" pages="10-90" password="adobe">
</cfpdf>

Note: When you use the cfpdfparam tag with the cfpdf merge action, you must specify either the destination attribute or the name attribute for the cfpdf tag.

Example

The following ColdFusion page creates a form for downloading tax forms and tax information booklets:

<h3>Downloading Federal Tax Documents</h3>
<p>Please choose the your type of business.</p>
<!--- Create the ColdFusion form to determine which PDF documents to merge. --->
<table>
<cfform action="cfpdfMergeAction.cfm" method="post">
    <tr><td><cfinput type="radio" name="businessType" Value="SoleP">
        Sole Proprieter</td></tr>
    <tr><td><cfinput type="radio" name="businessType" 
        Value="Partner">Partnership</td></tr>
    <tr><td><cfinput type="radio" name="businessType" Value="SCorp">S Corporation</td></tr>
    <cfinput type = "hidden" name = "selection required" value = "must make a selection">
    <tr><td><cfinput type="Submit" name="OK" label="OK"></td></tr>
    </tr>
</cfform>
</table>

The ColdFusion action page merges PDF files in different locations based on the selection in the form:

<!--- Create a merged PDF document based on the selection in the form. --->
<cfpdf action="merge" name="taxDoc">
    <cfif #form.businessType# is "SoleP">
        <cfpdfparam source="taxForms\f2106ez.pdf">
        <cfpdfparam source="taxForms\f1040.pdf">
        <cfpdfparam source="taxForms\f1040sc.pdf">
        <cfpdfparam source="taxInfo\i1040sc.pdf">
        <cfpdfparam source="taxInfo\i2106.pdf">
        <cfpdfparam source="taxInfo\i1040sc.pdf">
        <cfpdfparam source="taxInfo\p535.pdf">
        <cfpdfparam source="taxInfo\p560.pdf">
        <cfpdfparam source="taxInfo\p334.pdf">
    <cfelseif #form.businessType# is "Partner">
        <cfpdfparam source="taxForms\f1065.pdf">
        <cfpdfparam source="taxForms\f1065b.pdf">
        <cfpdfparam source="taxForms\f1065bsk.pdf">
        <cfpdfparam source="taxForms\f8804.pdf">
        <cfpdfparam source="taxForms\f8825.pdf">
        <cfpdfparam source="taxInfo\p535.pdf">
        <cfpdfparam source="taxInfo\p560.pdf">
        <cfpdfparam source="taxInfo\i1065bsk.pdf">
    <cfelseif #form.businessType# is "SCorp">
        <cfpdfparam source="taxForms\f1120s.pdf">
        <cfpdfparam source="taxForms\f2553.pdf">
        <cfpdfparam source="taxForms\f8453s.pdf">
        <cfpdfparam source="taxForms\f8825.pdf">
        <cfpdfparam source="taxInfo\i1120s.pdf">
        <cfpdfparam source="taxInfo\p542.pdf">
        <cfpdfparam source="taxInfo\p535.pdf">
        <cfpdfparam source="taxInfo\p560.pdf">
    </cfif>
</cfpdf>

<cfpdf action="write" source="taxDoc" destination="c:\taxDoc.PDF"
    overwrite="yes"/>

Note: ColdFusion automatically flattens form fields when you use the merge action of the cfpdf tag.