Skip to main content
Participant
Jan 13, 2021 7:44 PM UTC
Question

CFHTMLTOPDFITEM Header

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 is closed to new replies. Start a new post to keep the conversation going.

4 replies

James Moberg
Inspiring
Jan 15, 2021 10:58 PM UTC

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.)

Translate
BKBK
Community Expert
Community Expert
Jan 16, 2021 10:42 AM UTC

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:

 

Translate
BKBK
Community Expert
Community Expert
Jan 15, 2021 7:50 PM UTC
BKBK
Community Expert
Community Expert
Jan 15, 2021 7:39 PM UTC

@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".

Translate