mikehaertl / phpwkhtmltopdf

A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface
MIT License
1.6k stars 238 forks source link

Add methods addHeader and addFooter #335

Closed tflori closed 5 years ago

tflori commented 5 years ago

Why to have a cover when you can't add footer and header?

The difference between a page and a cover is that the footer and header are not visible on this page. It would be nice to have the footer and header options...

wkhtmltopdf --footer /path/to/footer.html --header /path/to/header.html /path/to/input.html /path/to/output.html

mikehaertl commented 5 years ago

Are you sure you're asking this in the right place? This here is not wkhtmltopdf but the PHP wrapper. We can't implement features that wkhtmltopdf does not support. But maybe I don't understand what exactly you're asking for.

tflori commented 5 years ago

sorry, maybe it was somehow unclear described. in fact we are using another php wrapper for wkhtmltopdf but this is also missing this functionality (snappy).

at least in the wrapper we are using you can define the html $wrapper->loadHtml($html) without creating a file and adding a page and so on. It would be nice to provide the header and footer the same way. $wrapper->addHeader($html) without the need to create a file (temporary; because you don't have the html, you have a template engine that generates html) and adding the option --header-html /path/to/header.html.

of course the same goes for the footer.

mikehaertl commented 5 years ago

But you don't have to create files. Our class takes care of this. You can simply pass HTML for any header-* or footer-* option: https://github.com/mikehaertl/phpwkhtmltopdf#passing-strings

mikehaertl commented 5 years ago

More precisely: We use a regex to find the options that expect a filename/URL and try to create a tmp file when possible (https://github.com/mikehaertl/phpwkhtmltopdf/blob/master/src/Pdf.php#L31).

tflori commented 5 years ago

oh wow. that's great! sorry for bothering :)