I am using dompdf (a PHP library) to create a PDF page and I have a problem to set proper dimensions. When I use CSS property:
@page {
size: 21cm 29.7cm;
}
… and for example I want to have the upper part of the page in red color, the PDF file is OK, but after print I got white margin. How can I fix it?
nolbadi111:
Did you set the right paper size, with setPaper() function?
Reference: https://github.com/dompdf/dompdf
Ok, so the problem was not with the domPDF, but with the printer settings. To acheive the goal you have to set borderless property.
btw. when you use
you don't need to set page size property in css (but it helps during creating page in html)
You've set the size of the page, but not the content boundaries. If you don't want any border on the page you have to set the page margins to 0.
This removes the margin around the body, but it also means that your content will bump up against the page edge. If you want the body content to having some spacing from the edge give it some padding.