Skip to content
Advertisement

dompdf HTML to PDF – can’t set margin of page

version: 0.6.0 beta 3

I tryed in every manner to make dompdf set the margin of the page. I have a long page with a lot of text, divided in chapters…

my css is something like:

JavaScript

when the php is

JavaScript

but what I get is a page with NO margins!!! only the padding of the #wrapper are applied… and they are applyed only at the beginning and at the end of the entire PDF…

I’m doing something wrong?

PS – it seems that only the bottom-margin is applied… but I’m not sure…

PPS – I tryed with no success also this css: body { margin-top: 40px; } html { margin-top: 40px; } @page { margin-top: 40px; }

Advertisement

Answer

I figured out that neither body or @page works in this version of dompdf.

the problem was in the main CSS, where I put every tyme this line:

JavaScript

I find out that margins of the PDF are decided in base of the margin of the HTML, so I removed that line with the global selector and replaced with:

JavaScript

This works as “un-expected” and I get the right margin in every page.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement