PDF Margins
When generating PDFs with PdfUtils::savePdfFromHTML(), PDF Core allows page margins to be configured to control how close content is rendered to the edge of the page. Margins are measured in millimeters and help ensure content remains within the printable area of most printers.
If no margin values are specified, PDF Core uses default margins of 15 mm on all sides of the page.
Available Margin Options
The following options may be passed to PdfUtils::savePdfFromHTML():
marginTopinteger. Default is15. Sets the top page margin in millimeters.marginBottominteger. Default is15. Sets the bottom page margin in millimeters.marginLeftinteger. Default is15. Sets the left page margin in millimeters.marginRightinteger. Default is15. Sets the right page margin in millimeters.
Example
The following example generates a PDF using 25 mm margins on all sides:
PdfUtils::savePdfFromHTML(
$html,
'applicationToPrint.pdf',
[
'creator' => $this->user->get('id'),
'author' => 'Benner Library PDF Printer',
'font' => [
'family' => 'Times',
'size' => 12
],
'marginTop' => 25,
'marginBottom' => 25,
'marginLeft' => 25,
'marginRight' => 25
]
);