<cfdocument>

Creates a PDF document from a text block containing CFML and HTML.

Note that Word and Excel conversion is not available.

This tag may have a body.

This tag is also supported within <cfscript>

Requires Extension: PDF Extension

<cfdocument backgroundvisible=boolean encryption=String filename=String fontembed=string fontdirectory=string format=string page=any margin=any marginbottom=number marginleft=number marginright=number margintop=number mimetype=string name=string orientation=string overwrite=boolean ownerpassword=string pageheight=number pagewidth=number pagetype=string permissions=string scale=number src=string srcfile=string type=string unit=string userpassword=string proxyhost=string proxyport=number proxyuser=string proxypassword=string bookmark=boolean htmlbookmark=boolean localurl=boolean authuser=string authpassword=string useragent=string saveasname=string ><!--- body --->[</cfdocument>]
Attribute Description
encryption
String, optional

define if the output should be encrypted and how deep

filename
String, optional

name for output file, if not defined output will be written to response stream

fontembed
string, optional

define if fonts will embedded with the file

fontdirectory
string, optional

directory that contains additional font files (.ttf) and a pd4fonts.properties to describe them.

Note: Classic engine works using the font-family-name from pd4fonts.properties file. Modern (Flying saucer) engine works using the font-family-name from the .ttf file with the same case.

format
string, optional

format of the created file

page
any, optional

Specifies the page info in a struct like this {width:10, height:5, type:A4}

margin
any, optional

Specifies the margin in inches (default), centimeters or points. The attribute unit controls the type. possible values is a number, so margin is the same all around, or a struct like this {top:1,bottom:1,left:2,right:2}

marginbottom
number, optional

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

marginleft
number, optional

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

marginright
number, optional

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

margintop
number, optional

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

mimetype
string, optional

mimetype of the source (when attribute src or srcfile are defined)

name
string, optional

name of a variable to store the output in it

Alias: variable

orientation
string, optional

Page orientation. Can be "landscape" or "portrait". Defaults to "portrait".

overwrite
boolean, optional

define if an existing file will be overwritten or not

ownerpassword
string, optional

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

pageheight
number, optional

used when pagetype is custom

pagewidth
number, optional

used when pagetype is custom

pagetype
string, optional

defined the used format for the page (,legal,letter,A4,A5,B4,B5,B4-JIS,B5-JIS and custom)

permissions
string, optional

Sets the permissions for the document

  • AllowPrinting
  • AllowModifyContents
  • AllowCopy
  • AllowModifyAnnotations
  • AllowFillIn
  • AllowScreenReaders
  • AllowAssembly
  • AllowDegradedPrinting
src
string, optional

define a url or a relative path on the local system to a file that should be transferred to a pdf

srcfile
string, optional

define an absolute path to a file that should be transferred to a pdf

type
string, optional

Specifies which engine should be used to render the document.

Options are:

  • classic
  • modern (Available since PDF Extension version 1.0.0.92)

Defaults to the Application's this.pdf.type setting (which defaults to "modern").

unit
string, optional

set the unit for pageheight, pagewidth, and margin...

userpassword
string, optional

Specifies a user password (format="PDF" only). Defaults to "empty" if is not set, and encryption is set to 40 bit or 128 bit.

proxyhost
string, optional

alias for proxyHost

Alias: proxyserver

proxyport
number, optional

The port number on the proxy server from which the object is requested. Default is 80. When used with resolveURL, the URLs of retrieved documents that specify a port number are automatically resolved to preserve links in the retrieved document.

proxyuser
string, optional

When required by a proxy server, a valid username.

proxypassword
string, optional

When required by a proxy server, a valid password.

bookmark
boolean, optional

Specifies whether bookmarks are created in the document

htmlbookmark
boolean, optional

If true, it is possible to convert outlines to a list of named anchors (<a name="anchor_id">label</a>) or a headings structure (<h1>...<h6>). Transforming of HTML hyperlinks to PDF hyperlinks (if not explicitly disabled). Hyperlink jumps within the same document are supported as well

localurl
boolean, optional

Specifies whether to retrieve image files directly from the local drive

authuser
string, optional

User name sent to the target URL for Basic Authentication. Combined with password to form a base64 encoded string that is passed in the Authenticate header. Does not provide support for Integrated Windows, NTLM, or Kerberos authentication.

authpassword
string, optional

Password sent to the target URL for Basic Authentication. Combined with username to form a base64 encoded string that is passed in the Authenticate header. Does not provide support for Integrated Windows, NTLM, or Kerberos authentication.

useragent
string, optional

Text to put in the HTTP User-Agent request header field. Used to identify the request client software.

saveasname
string, optional

(format="PDF" only) The filename that appears in the SaveAs dialog when a user saves a PDF file written to the browser.

Unimplemented Attribute(s)

Attribute Description
backgroundvisible
boolean, optional

Specifies whether the background prints when the user prints the document

* unimplemented *
scale
number, optional

Define a scale factor as a percentage. This option is used to reduce the size of the HTML output so that it fits on that paper. Define a number less than 100.

* unimplemented *

Examples

Simple example for cfdocument

<cfdocument format="pdf">
	<h1>Welcome to Lucee</h1>
	<h5>Example Page</h5>
	<p>Example for <b>Cfdocument</b></p>
</cfdocument>

See also