Skip to main content
Matthew C. Parks
Inspiring
August 12, 2016
Question

<cfhtmltodpf> margin

  • August 12, 2016
  • 2 replies
  • 1357 views

Attempting to resolve an issue and I have reduced issue down to simplest form.

<cfhtmltopdf unit="in" marginBottom="1" marginLeft="1" marginRight="1" marginTop="1" orientation="portrait" pageType="letter">

this is a test <cfoutput>#now()#</cfoutput>

</cfhtmltopdf>

The Top Margin in 1 3/16 inch and Left margin in 1 1/16 inch.  In my code the margins are 1 5/16 for top and 1 3/16 for left, but we have HTML tags and style that I am thinking I will have to tweak, but the above example should give one inch and one inch on top and left margin and it is not.

Is there anything that I can do to correct this issue?  It seems like a PDF service issue to me.

CF ENT 11, update 9 on Windows Server 2012 R2 64 bit.

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
August 13, 2016

Please let us know what the issue is. I tested your code with

<cfprocessingdirective suppressWhiteSpace = "yes">

<cfhtmltopdf unit="in" marginBottom="1" marginLeft="1" marginRight="1" marginTop="1" orientation="portrait" pageType="letter">this is a test <cfoutput>#now()#</cfoutput></cfhtmltopdf><cfcontent type="application/pdf">

</cfprocessingdirective>

and then with

<cfprocessingdirective suppressWhiteSpace = "yes">

<cfhtmltopdf unit="in" marginBottom="1" marginLeft="1.1875" marginRight="1" marginTop="1.3125" orientation="portrait" pageType="letter">this is a test <cfoutput>#now()#</cfoutput></cfhtmltopdf><cfcontent type="application/pdf">

</cfprocessingdirective>

I got 2 PDF documents with respective margins (marginLeft=1, marginTop=1) and (marginLeft=19/16, marginTop=21/16), as expected.

Matthew C. Parks
Inspiring
August 14, 2016

When I generate the odd with 1 set to all margins the margin is larger than 1 inch.  I thought I had explained that in my original post.  But that is the problem.  No html used at all just the example code I posted margins are off by 1/16 of an inch on left and 3/16 on top

BKBK
Community Expert
Community Expert
August 14, 2016

Ah, it's clear. Then remove all white space, for example, as in

<cfprocessingdirective suppressWhiteSpace = "yes"><cfhtmltopdf unit="in" marginBottom="1" marginLeft="1" marginRight="1" marginTop="1" orientation="portrait" pageType="letter">this is a test <cfoutput>#now()#</cfoutput></cfhtmltopdf></cfprocessingdirective>

WolfShade
Legend
August 12, 2016

What about your HTML?  Have you set the outer containing element (div, table, etc.) to have 0px padding and margin?

V/r,

^_^