How can I use footers and headers with wkhtmltopdf?

I encountered a situation where I had to use footers and headers in my generated PDF printounts. CSS solution works for the first page only. And the only information I found is that it is not supported in WKPDF at all, but this dates back to 2009, so something might have changed.

Has anyone succeeded in doing it?

Thank you.


Solution 1:

Wkhtmltopdf does support even very complex headers and footers.

wkhtmltopdf.exe -T 50mm --header-html www.google.com www.stackoverflow.com test.pdf && test.pdf

That command uses the page at www.google.com as a 50mm header for www.stackoverflow.com for every page.

Note: If you use a custom page for the header/footer, you need to add <!DOCTYPE HTML> in the beginning of your header/footer HTML!