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 does support even very complex headers and footers. 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!
In order to force a page break or new page in a PDF for wkhtmltopdf or Headless Chrome, you need to use the page-break rules. The easiest way is to setup a <div> tag and then apply the style directly to the <div> that wraps the content you want to appear on individual pages.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With