How can I use footers and headers with wkhtmltopdf?

Wkhtmltopdf

Wkhtmltopdf Problem Overview


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.

Wkhtmltopdf Solutions


Solution 1 - Wkhtmltopdf

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!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVladimir HrabanView Question on Stackoverflow
Solution 1 - WkhtmltopdfJoel PeltonenView Answer on Stackoverflow