Menu Close

How to set the margin of a document in dompdf?

How to set the margin of a document in dompdf?

The following style will effectively set the margins of your document to 0: @page is used by dompdf 0.6.0, body by dompdf 0.5.1. You can modify the margin of the page and body independently, though right now the margin of the two together acts as your content bounds.

Where does the header and footer go in dompdf?

@tapulator not in dompdf. Content is placed relative to the content area of the page, i.e. the body element. Since the page margins are outside the body element you want to push the header/footer into this space. bottom positioning indicates how far up from the bottom of the containing box you want to be.

When to use @ page and body in dompdf?

@page is used by dompdf 0.6.0, body by dompdf 0.5.1. You can modify the margin of the page and body independently, though right now the margin of the two together acts as your content bounds. Thanks for contributing an answer to Stack Overflow!

How big should the margins be on a PDF?

You need to provide the dimensions of the page as well according to your needs. The following example generates a PDF of 2 pages with margins of the described height:

The following style will effectively set the margins of your document to 0: @page is used by dompdf 0.6.0, body by dompdf 0.5.1. You can modify the margin of the page and body independently, though right now the margin of the two together acts as your content bounds.

Is it easy to add a header in dompdf?

Header and/or footer on every page Adding a page header or footer on every page is basically very easy with Dompdf just by setting the position of the element to “fixed” – at least theoretically. Because there are at least two preconditions that must be met and are not so obviously documented (or not at all):

When to use @ page or body in dompdf?

@page is used by dompdf 0.6.0, body by dompdf 0.5.1. You can modify the margin of the page and body independently, though right now the margin of the two together acts as your content bounds.

Why are images inside tables so small in dompdf?

I’ve finally found a bug report on Dompdf’s Github page, telling that images inside tables can get really very small. Another user reported the same problem, while the project maintainer couldn’t find a way to reproduce the problem. I was rather guessing that this has to do with different system environment, especially different PHP versions.