Node-html-pdf: Phantom.js-free replacement with headless Chrome

Created on 19 Jul 2017  Â·  6Comments  Â·  Source: marcbachmann/node-html-pdf

Since Phantom.js had its maintainer step down and cited headless Chrome as one of the reasons, I have decided to start building a replacement library that uses headless Chrome, html-pdf-chrome.

Most helpful comment

Thanks. Sadly chromium isn't as far as phantomjs regarding page customizations.
E.g. you can't even set a header & footer

And exactly this was the initial reason I've chosen phantomjs. If you don't need those, a headless chromium is the best solution at the moment.

All 6 comments

Thanks. Sadly chromium isn't as far as phantomjs regarding page customizations.
E.g. you can't even set a header & footer

And exactly this was the initial reason I've chosen phantomjs. If you don't need those, a headless chromium is the best solution at the moment.

Yes, some features will require a bit more custom code. Headers/footers are tracked here: https://github.com/westy92/html-pdf-chrome/issues/16.

custom page header/footer can be achieved by using native css features that I'm sure modern chrome versions support:
https://www.w3.org/TR/css3-page/#margin-boxes

@benjamine – have you tried using margin-boxes with Chrome though? It doesn't appear to work.

Headless chrome (puppeteer) now supports custom headers and footers (see headerTemplate and footerTemplate options). We've made the switch and it's definitely an improvement.

One issue to be aware of is that CSS margins override any margins passed to the page.pdf API (https://github.com/GoogleChrome/puppeteer/issues/393).

I love this idea @marcbachmann !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tashikomaaa picture tashikomaaa  Â·  5Comments

rayax86 picture rayax86  Â·  5Comments

tsp1996 picture tsp1996  Â·  5Comments

ZBilel picture ZBilel  Â·  4Comments

vivekiyer114 picture vivekiyer114  Â·  5Comments