Live data from Hacker News

Firefox 56 supports headless mode on Windows

bugzilla.mozilla.org

41–50 of 88 posts

Re: Firefox 56 supports headless mode on Windows

#43
post #12

I was wondering if I could use this (using a plugin) or Chrome to generate PDF files on the web server. Most of the PDF generation software out there are quite expensive.

We used node-html-pdf[1] for this, but it depends on phantomjs which uses an ancient version of webkit. We migrated to electron and its contents.printToPDF(options, callback), but that has the drawback that we have to start a X-server[2] with our backend code. I have hopes with a headless chrome we can ditch the xvfb-server and have one less dependencies. The setup is a pain, but the results are very good and looking very decent.

[1] https://github.com/marcbachmann/node-html-pdf [2] https://en.wikipedia.org/wiki/Xvfb

Re: Firefox 56 supports headless mode on Windows

#44
post #12

I was wondering if I could use this (using a plugin) or Chrome to generate PDF files on the web server. Most of the PDF generation software out there are quite expensive.

Latex is free.

Really not the same thing (e.g. pandoc for html -> pdf via LaTeX) as having a webkit based renderer. They do not look the same at all; sometimes it is good to have a LaTeX output but most of the time you are going to want a more accurate representation of your HTML.

Re: Firefox 56 supports headless mode on Windows

#46
post #19
post #15

Earlier quoted context omitted.

We use wkhtmltopdf to do this server side. It as a few problems and quirks, but it work well enough for us.

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 recom…

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.

Re: Firefox 56 supports headless mode on Windows

#47
post #36

It's not very clear how to actually use this in a test environment like Selenium etc. At least with headless Chrome there are libraries now to drive it via the remote debug protocol like https://github.com/LucianoGanga/simple-headless-chrome This feels a little nicer than Selenium as it's one less layer of abstraction. EDIT: guess from other comments WebDriver is the right method to access.

for automated testing in a non windowed env, this can be used.

Re: Firefox 56 supports headless mode on Windows

#48
post #6

Is there a linux headless mode already? Selenium chrome driver headless is pretty much useless in linux because important methods like `send_keys` need X anyway for keyboard mappings or something like that.

Genuine noob question: could you not use Xvfb?

you can, and it worked, prior to availability of headless options(Phantom sucks). However xvfb is yet another dependency that could cause breakage.

Re: Firefox 56 supports headless mode on Windows

#49
post #12

I was wondering if I could use this (using a plugin) or Chrome to generate PDF files on the web server. Most of the PDF generation software out there are quite expensive.

Latex is free.

My time isn't. Sometimes the most cost effective option isn't the one with the lowest price tag.

Re: Firefox 56 supports headless mode on Windows

#50
post #40

Does that mean we'll soon have an alternative to ElectronJS / NWJS based on Firefox ? (Positron :p ?)

It already exists: https://github.com/mozilla/positron

Checked. Discontinued. It used to be prism or something but that was discontinued years ago.

The sometimes really make it hard for us fanboys (prism, Brendan and uncertainty about the future of extensions) :-|

Post reply on HN