cfdocument
Description
Creates PDF or FlashPaper output from a text block containing CFML and HTML.
Category
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: Added this tag.
Attributes
Attribute | Req/Opt | Default | Description |
---|---|---|---|
format | Required | Specifies the report format:
| |
filename | Optional | Specifies the name of a file to contain the PDF or FlashPaper output.
If you omit the | |
overwrite | Optional | no | Specifies whether Adobe 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 | A4 | Specifies the page size into which Adobe ColdFusion generates the report:
|
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 | portrait | Specifies the page orientation:
|
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 | in | Specifies the default unit for the pageheight , pagewidth , and margin attributes:
|
encryption | Optional | None | (format="PDF" only) Specifies whether the output is encrypted:
|
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:
Separate multiple permissions with a comma. | |
fontembed | Optional | yes | Specifies whether Adobe ColdFusion embeds fonts in the output:
Selective: embed all fonts except Java fonts and core fonts. For more information, see Usage. |
backgroundvisible | Optional | no | Specifies whether the background prints when the user prints the document:
|
scale | Optional | Calculated by Adobe 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. |
Usage
Use the cfdocument
tag to render HTML and CFML output into PDF or FlashPaper format. Adobe 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, Adobe 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 Adobe 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>