I'm using PhantomJS to generate PDFs from HTML. I want to have a page footer that says "page 1 of 5", "page 2 of 5", etc. Is there any way to do that with PhantomJS?
(I know about CSS3 page-based counters, but as far as I can tell PhantomJS doesn't support them.)
Yes, it's possible.
Look at the printheaderfooter.js example on GitHub.
Basically, two callbacks are invoked when printing : one for header and another for footer. It's not in the doc, but the example is easy to understand.
The only problem you may have with this feature is if you want to apply custom styling or include images. Sometimes, it's a bit tricky...
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