Skip to main content
Matthew C. Parks
Inspiring
Aug 12, 2016 12:31 PM UTC
Question

<cfhtmltodpf> margin

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

6 replies

BKBK
Community Expert
Community Expert
Aug 13, 2016 7:33 PM UTC

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.

Translate
Matthew C. Parks
Inspiring
Aug 14, 2016 1:17 AM UTC

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

Translate
BKBK
Community Expert
Community Expert
Aug 14, 2016 2:07 AM UTC

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>

Translate
WolfShade
Legend
Aug 12, 2016 1:16 PM UTC

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

V/r,

^_^

Translate