cfhtmltopdfitem

<cfhtmltopdfitem> specifies the action items for a PDF document created by the <cfhtmltopdf> tag.  The type attribute takes the following values:

  • header
  • footer
  • pagebreak

Category

Data output tags

Syntax

<cfhtmltopdfitem>
type = header/footer/pagebreak
isBase64 = "yes|no"
showonprint = "yes|no"
align = "left|right|center"
evalAtPrint = "true|false"
marginleft = "number"
marginright = "number"
margintop = "number"
marginbottom = "number"
opacity = "number”
numberformat = "LOWERCASEROMAN|NUMERIC|UPPERCASEROMAN"
image = " URL|pathname absolute or relative to web root"
</cfhtmltopdfitem>

History

  • ColdFusion (2016 release) Update 3 - Added the attribute evalAtPrint.
  • ColdFusion (2016 release) - Added the CFHTMLTOPDF.currentPageNumber and CFHTMLTOPDF.totalPageCount scope variables.
  • ColdFusion 11 Update 3 - Added the _CURRENTPAGENUMBER and _TOTALPAGECOUNT scope variables.

Attributes

Attribute

Req/Opt

Default

Description

type

Required

none

Specifies the action:

  • header: uses the text/image specified between the <cfhtmltopdfitem> and </cfhtmltopdfitem> tags as the running header.
  • footer: uses the text/image between the <cfhtmltopdfitem> and </cfhtmltopdfitem> tags as the running footer.
  • pagebreak: can be used to insert a pagebreak in the generated PDF. When <cfhtmltopdf> is used as a service, pagebreak will not work.

 

Note: When the type is "header", the marginbottom attribute will not be supported. Similarly, when type is "footer", the margintop attribute will not be supported.

isBase64

Optional

 

Yes/No. Use this only when the image attribute is given a base64 image string.

showonprint

Optional

 

Show or hide header/footer when the document is printed.

align

Optional

Center

Alignment of the text. Left, Right, or Center.

evalAtPrint

Optional

false

If set to true, then the content of cfhtmltopdfitem is evaluated after the PDF has been generated and the page numbers are available for each page. This allows you to have some conditional code inside the cfhtmltopdfitem.

Note: If evalAtPrint=true, the numberformat attribute must be set to numeric.

marginleft

Optional

1.0

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

marginright

Optional

1.0

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

margintop

Optional

0.5

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

marginbottom

Optional

0.5

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

opacity

Optional

10

Opacity of the header/footer. Specify a valid number. A number between 1 and 10.

numberformat

Optional

Numeric

The page number format to be used. LOWERCASEROMAN|NUMERIC|UPPERCASEROMAN

image

Optional

 

The image file name or object to be used as header or footer.

The following parameters are supported:

  • A path to the image file
  • A Base-64 string
  • A byte array
  • A <cfimage> object

Example

<cfhtmltopdf destination="myPDF.pdf" source="http://somesite.com" overwrite="true">
<cfhtmltopdfitem type="header">
Page: _PAGENUMBER of _LASTPAGENUMBER 
</cfhtmltopdfitem>
<cfhtmltopdfitem type="pagebreak" />
<cfhtmltopdfitem type="footer" image="test.jpg">
</cfhtmltopdfitem>
</cfhtmltopdf>

This tag supports very limited HTML in its body. This tag only supports these 5 HTML tags: <body>, <p>, <i>, <b> and <span>.

The complete reference of HTML supported is listed here.

You can access the following scope variables in <cfhtmltopdfitem> content:

  • _PAGENUMBER – Add current page number.
  • _LASTPAGENUMBER – Add last page number.
  • _CURRENTPAGENUMBER - Add current page number.

  • _TOTALPAGECOUNT - Add total page count.
  • CFHTMLTOPDF.currentPageNumber – Add current page number.
  • CFHTMLTOPDF.totalPageCount – Add total page count.

 Adobe

Recevez de l’aide plus rapidement et plus facilement

Nouvel utilisateur ?

Adobe MAX 2024

Adobe MAX
La conférence sur la créativité

Du 14 au 16 octobre à Miami Beach et en ligne

Adobe MAX

La conférence sur la créativité

Du 14 au 16 octobre à Miami Beach et en ligne

Adobe MAX 2024

Adobe MAX
La conférence sur la créativité

Du 14 au 16 octobre à Miami Beach et en ligne

Adobe MAX

La conférence sur la créativité

Du 14 au 16 octobre à Miami Beach et en ligne