Using wkhtmltopdf 0.12.6 and mikehaertl's phpwkhtmltopdf I'm trying to add a header and footer to each page while setting the header and footer spacing. This used to work when using an older binary file, but we recently switched to 0.12.6 installed on the server. The server is running on AlmaLinux 8.7.
Creating the file:
$pdf_options = array(
'load-error-handling' => 'ignore',
'ignoreWarnings'=> true,
'enable-javascript',
'dpi' => '300',
'no-outline',
'margin-bottom' => '0mm',
'margin-top' => '0mm',
'margin-left' => '0mm',
'margin-right' => '0mm',
'header-html' => '/path/to/header.html',
'footer-html' => '/path/to/footer.html',
'header-spacing' => 20,
'footer-spacing' => 15,
);
$pdf = new Pdf($pdf_options);
$pdf->addPage($html);
$pdf->send('pdf.pdf');
Expected output: Expected output
Given output Given output
As you can see, the spacing is lost and there is no header or footer. What can cause the issue?
Found the solution myself after fiddling around. Setting the header-spacing and footer-spacing without the margin-top and margin-bottom does not work. Applying both options makes it work. Also setting just the margin puts the header over of the real text and not above it.