Skip to main content
Participant
January 13, 2021
Question

CFHTMLTOPDFITEM Header

  • January 13, 2021
  • 3 replies
  • 410 views

Hello,

 

Has anyone had success with centering or spanning the entire PDF with a header image?  When I add a header image with the code below, it is always left aligned no matter if I use the align attribute (which says it is for text) or if I increases the width of the image (it appears to be cropped).

 

<cfhtmltopdfitem type="header" image="pathto/simple_head.png" />

 

I would like to use the Coldfusion to PDF capability because I need to deliver my user accessible PDF's on demand.

 

Thanks!

This topic has been closed for replies.

3 replies

James Moberg
Inspiring
January 15, 2021

We've been using WKHTMLTOPDF for all PDF generation (since ColdFusion 9) and when centering any images, we use HTML and a DIV with "margin:0 auto;".  (I'm sharing this because I understand that CFHTMLTOPDF is black-boxed version of an older version of WKHTMLTOPDF.)

BKBK
Community Expert
Community Expert
January 16, 2021

I would second Jamo 's suggestion. But if, for what ever reason, you're stuck with cfhtmltopdf or if the project has to be delivered urgently, then you could work around the problem as follows:

  •  create a copy of the header/footer image that has the appropriate amount of whitespace to the left 

 

Something like:

 

BKBK
Community Expert
Community Expert
January 15, 2021
BKBK
Community Expert
Community Expert
January 15, 2021

@jfkerwin , you're right. I have verified that ColdFusion doesn't respond to the align attribute when the header or footer is an image. Only when the header or footer's content is text.

 

Counterintuitive, yes. But we should perhaps have expected it. The cfhtmltopdfitem documentation says the align attribute is for "Alignment of the text".