News for hackers. Stuff that matters.
Re:Firefox 56 supports headless mode on Windows by mchiron on Thursday June 22, 2017 @07:11AM (#14611368)
We use wkhtmltopdf to do this server side. It as a few problems and quirks, but it work well enough for us.
Re:Firefox 56 supports headless mode on Windows by pilif on Thursday June 22, 2017 @07:26AM (#14611423)
it has a lot of quirks, and, frankly, webkit is pretty bad at printing in general as it lacks a ton of printing specific features like re-printing table headers across page boundaries.

There's also only very rudimentary support for page headers and footers.

wkhtmktopdf is probably ok if you just need a quick single page invoice printout, but the moment you need more (in our case, we definitely do), I can highly recommend paying for https://www.princexml.com/ which has support for a lot of printing specific features.

Re:Firefox 56 supports headless mode on Windows by bowersbros on Thursday June 22, 2017 @10:17AM (#14612379)
One of the issues we had with wkhtmltopdf was that we use Angular for our views, and we have a view for an invoice, and the ability to print it.

We wanted the same view to be passed into wkhtmltopdf to download it as PDF (with a couple of things omitted).

Unfortunately, the JS didn't execute properly, so you get a borked output.

End result was we render it, capture the HTML after render, and pipe that through to wkhtmltopdf.

Using chrome _should_ resolve that issue and let us just pass the page through.

Re:Firefox 56 supports headless mode on Windows by veza on Thursday June 22, 2017 @09:30AM (#14612064)
wkhtmltopdf works quite well for us, even with modern web technologies.

Here's an example fully rendered in React: https://s3.amazonaws.com/ud-reports/comps-report-86.pdf

And one with svg charts: https://s3.amazonaws.com/ud-reports/chart-report-89.pdf

With -webkit- prefixes you can use even flexbox, and and with js polyfills you'll have all you need.

Of course if I would start a project now, I would use chrome headless, but I don't feel wkhtmltopdf is that bad.