I'm developing an electronic invoicing system, and one of our features is generating PDFs of the invoices, and mailing them. We have multiple templates for invoices, and will create more later, so we decided to use HTML templates, generate HTML document, and then convert it to PDF. But we're facing a problem with wkhtmltopdf, that as far as I know (I've been Googleing for days to find the solution) we cannot simply both use HTML as header/footer, and show page numbers in them.
In a bug report (or such) ( http://code.google.com/p/wkhtmltopdf/issues/detail?id=140 ) I read that with JavaScript it is achievable this combo. But no other information on how to do it can be found on this page, or elsewhere.
It is, of course not so important to force using JavaScript, if with wkhtmltopdf some CSS magic could work, it would be just as awesome, as any other hackish solutions.
Thanks!
Refer to Adding Content to a Header or Footer for an example of how to create content for a header or footer. 2. Highlight numbered-header then the Edit button to open the Generated Text Editor. Place your cursor in the right hand cell of the header table, then choose Insert > Page Number.
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!
To change the numbering alignment, go to Header & Footer > Page Number > Page Number. Choose the alignment you want and select OK. Go to Header & Footer > Close Header and Footer or double-click outside the header to exit.
Actually it's much simpler than with the code snippet. You can add the following argument on the command line: --footer-center [page]/[topage]
.
Like richard mentioned, further variables are in the Footers and Headers section of the documentation.
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