barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.59k stars 289 forks source link

DPI 300 footer/header issues #509

Open uvolos opened 11 months ago

uvolos commented 11 months ago

With DPI 96 all looks fine With DPI 300 header/footer moving to the center of page

DPI 96 Снимок экрана 2023-07-18 в 13 19 48

DPI 300 Снимок экрана 2023-07-18 в 13 20 13

Example:

$pdf = \App::make('snappy.pdf.wrapper');

$pdf->setOptions([
    'disable-smart-shrinking' => true,
    'page-size' => 'A4',
    'orientation' => 'portrait',
    'dpi' => 300, // 96
]);

function htm($content) {
   return "<!DOCTYPE html><html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head><body>$content</body></html>";
}
$pdf->setOption('header-html', htm('<div style="background: red;">HEADER</div>'));
$pdf->setOption('footer-html', htm('<div style="background: blue;">FOOTER</div>'));
$pdf->loadHTML(htm('<div style="background: green">CONTENT</div>'));

$response = $pdf->download();
uvolos commented 11 months ago

UPD: wkhtmltopdf issue https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3378