CFDOCUMENT |
Description Creates PDF or FlashPaper output from a text block containing CFML and HTML.
Category Data output tags
Syntax
    <cfdocument
       format = "PDF" or "FlashPaper"
       filename = "filename"
       overwrite = "yes" or "no"
       name = "output variable name"
       pagetype = "page type"
       pageheight = "page height in inches"
       pagewidth = "page width in inches"
       orientation = "portrait/landscape"
       margintop = "number"
       marginbottom = "number"
       marginleft = "number"
       marginright = "number"
       unit = "in" or "cm"
       encryption = "128-bit" or "40-bit" or "none"
       ownerpassword = "password"
       userpassword = "password"
       permissions = "permission list"
       fontembed = "yes" or "no"
       backgroundvisible = "yes" or "no"
       scale = "percentage less than 100">

       HTML and CFML code
    </cfdocument>
See also cfreport, cfdocumentitem, cfdocumentsection
History ColdFusion MX 7: Added this tag.
Usage Use the cfdocument tag to render HTML and CFML output into PDF or FlashPaper format. ColdFusion MX does not return HTML and CFML outside of the <cfdocument> </cfdocument> pair. The cfdocument tag can render HTML that supports the following standards: HTML 4.01 XML 1.0 DOM Level 1 and 2 CSS1 and CSS2 The cfdocument tag does not support the Internet Explorer-specific HTML generated by Microsoft Word. The PDF or FlashPaper document returned by the cfdocument tag overwrites any previous HTML in the input stream and ignores any HTML after the </cfdocument> tag. You cannot embed a cfreport tag in a cfdocument tag. When you use the cfdocument tag, ColdFusion MX creates a new scope named cfdocument. This scope contains the following variables: currentpagenumber totalpagecount
Note: | The cfdocument scope variables are reserved for page number rendering. Do not use them in ColdFusion expressions. For example, the following code does not work:
    <cfif cfdocument.currentpagenumber gt 1>
       <cfoutput>#cfdocument.currentpagenumber-1#</cfoutput>
    </cfif>
Example
    <cfdocument format="flashpaper">
    <p>This is a document rendered by the cfdocument tag.</p>

    <table width="50%" border="2" cellspacing="2" cellpadding="2">
      <tr>
        <td><strong>Name</strong></td>
        <td><strong>Role</strong></td>
      </tr>
      <tr>
        <td>Bill</td>
        <td>Lead</td>
      </tr>
      <tr>
        <td>Susan</td>
        <td>Principal Writer</td>
      </tr>
      <tr>
        <td>Adelaide</td>
        <td>Part Time Senior Writer</td>
      </tr>
      <tr>
        <td>Thomas</td>
        <td>Full Time for 6 months</td>
      </tr>
      <tr>
        <td>Michael</td>
        <td>Full Time for 4 months</td>
      </tr>
    </table>
    </cfdocument>

FORMAT |
| Required
Default value: "Specifies the report format:" PDF FlashPaper

FILENAME |
| Optional
Specifies the name of a file to contain the PDF or FlashPaper output. If you omit the filename attribute, ColdFusion MX streams output to the browser.

OVERWRITE |
| Optional
Default value: "no" Specifies whether ColdFusion MX overwrites an existing file. Used in conjunction with the filename attribute

NAME |
| Optional
Specifies the name of an existing variable into which the tag stores the PDF or FlashPaper output.

PAGETYPE |
| Optional
Default value: "A4" Specifies the page size into which ColdFusion generates the report: legal: 8.5 inches x 14 inches. letter: 8.5 inches x 11 inches. A4: 8.27 inches x 11.69 inches. A5: 5.81 inches x 8.25 inches. B5: 9.81 inches x 13.88 inches. Custom: custom height and width. If you specify custom, you must also specify the pageheight and pagewidth attributes, can optionally specify margin attributes, and can optionally specify whether the units are inches or centimeters.

PAGEHEIGHT |
| Optional
Specifies the page height in inches (default) or centimeters. This attribute is only valid if pagetype=custom. To specify page height in centimeters, include the unit=cm attribute.

PAGEWIDTH |
| Optional
Specifies the page width in inches (default) or centimeters. This attribute is only valid if pagetype=custom. To specify page width in centimeters, include the unit=cm attribute.

ORIENTATION |
| Optional
Default value: "portrait" Specifies the page orientation: portrait landscape

MARGINTOP |
| Optional
Specifies the top margin in inches (default) or centimeters. To specify the top margin in centimeters, include the unit=cm attribute.

MARGINBOTTOM |
| Optional
Specifies the bottom margin in inches (default) or centimeters. To specify the bottom margin in centimeters, include the unit=cm attribute.

MARGINLEFT |
| Optional
Specifies the left margin in inches (default) or centimeters. To specify the left margin in centimeters, include the unit=cm attribute.

MARGINRIGHT |
| Optional
Specifies the right margin in inches (default) or centimeters. To specify the right margin in centimeters, include the unit=cm attribute.

UNIT |
| Optional
Default value: "in" Specifies the default unit for the pageheight, pagewidth, and margin attributes: in: inches. cm: centimeters.

ENCRYPTION |
| Optional
Default value: "None" (format="PDF" only) Specifies whether the output is encrypted: 128-bit 40-bit none

OWNERPASSWORD |
| Optional
(format="PDF" only) Specifies an owner password.

USERPASSWORD |
| Optional
(format="PDF" only) Specifies a user password.

PERMISSIONS |
| Optional
(format="PDF" only) Specifies one or more of the following permissions: AllowPrinting AllowModifyContents AllowCopy AllowModifyAnnotations AllowFillIn AllowScreenReaders AllowAssembly AllowDegradedPrinting Separate multiple permissions with a comma.

FONTEMBED |
| Optional
Default value: "yes" Specifies whether ColdFusion embeds fonts in the output: yes: embed fonts. no: do not embed fonts. Selective: embed all fonts except Java fonts and core fonts. For more information, see Usage.

BACKGROUNDVISIBLE |
| Optional
Default value: "no" Specifies whether the background prints when the user prints the document: yes: include the background when printing. no: do not include the background when printing.

SCALE |
| Optional
Default value: "Calculated by ColdFusion" Specifies a scale factor as a percentage. Use this option to reduce the size of the HTML output so that it fits on that paper. Specify a number less than 100.