php-chrome-html2pdf
php-chrome-html2pdf copied to clipboard
Landscape Option Not Working
Hi there,
Thanks for this library - just switched to it from wkhtmltopdf, so please forgive me if this is due to my own ignorance.
It seems like the landscape option is not quite working? Or I'm missing setting something?
I've made sure I got all the dependencies installed on the server. Here's what I've done:
// Our input is HTML.
$input = new StringInput();
$input->setHtml($twigHtml);
// Initialise converter and set output as raw PDF content
$converter = new Converter($input, new StringOutput());
// Set page options.
$converter->setOptions([
'format' => 'A5',
'margin' => [
'top' => '1.5cm',
'right' => '1.5cm',
'bottom' => '1.5cm',
'left' => '1.5cm',
],
'landscape' => true
]);
// Return the raw PDF content.
return $converter->convert()->get();
I had to end up setting the preferCSSPageSize option to true and add the below to the @page at-rule in the CSS.
@page {
size: A5 landscape;
}
Thanks again, Zander