Live data from Hacker News

Headless mode in Firefox

developer.mozilla.org

81–90 of 191 posts

Re: Headless mode in Firefox

#81

Perhaps I'm spoiled, but I'm wondering why this wasn't a thing many years ago. Am I wrong in saying this was brought about in reaction to Chrome adding the same feature, or has this been there for a while? Clearly people wanted this for ages, hence the work on things like PhantomJS. But it seems like it was only added once they realized they needed to play catch-up with Chrome.

No, this has been in the works for a while

https://bugzilla.mozilla.org/show_bug.cgi?id=1338004

So not in reaction to Chrome.

In fact, the first attempt for this was almost a decade ago (https://bugzilla.mozilla.org/show_bug.cgi?id=446591)

Re: Headless mode in Firefox

#82

Earlier quoted context omitted.

Wow - thanks for posting that: could come in handy on the project I'm currently working on!

We're using Chrome Headless inside Docker to produce thousands of PDF reports from an Angular/D3 web app. It works very well, but there are some gotchas with regard to the Chrome Remoting Interface.

Is this open source? It would be very interesting to take a look at!

Re: Headless mode in Firefox

#83
post #34

Earlier quoted context omitted.

Remember that if you pass through any data from an outside source, you're running their code on your browser when you thought you were just printing a document. The security issues don't apply in all circumstances, of course, but if you feel like taking a shortcut to PDF generation and printing through a headless browser, you need to keep them in mind.

I highly recommend that anyone using a headless browser that may access outside sources employ something like this to run the headless browser in an external environment, in this case AWS Lambda: https://github.com/justengland/phantom-lambda-template I used this approach for a project at a previous company and not only did it keep the potentially unsafe external code execution isolated from the rest of the stack, but…

That's a neat approach, I'm not on anything like that scale though, looking for something to get rid of JasperReports.

Re: Headless mode in Firefox

#84

Perhaps I'm spoiled, but I'm wondering why this wasn't a thing many years ago. Am I wrong in saying this was brought about in reaction to Chrome adding the same feature, or has this been there for a while? Clearly people wanted this for ages, hence the work on things like PhantomJS. But it seems like it was only added once they realized they needed to play catch-up with Chrome.

No, this has been in the works for a while https://bugzilla.mozilla.org/show_bug.cgi?id=1338004 So not in reaction to Chrome. In fact, the first attempt for this was almost a decade ago ( https://bugzilla.mozilla.org/show_bug.cgi?id=446591 )

Thanks for the info, that's good news.

Re: Headless mode in Firefox

#89
post #53

Earlier quoted context omitted.

If only browsers supported creation of page headers and footers.

@page { @top-center { content: element(pageHeader); } } #pageHeader{ position: running(pageHeader); } http://www.w3.org/TR/css3-gcpm/#running-elements

Thank you for this. I've been doing this so wrong for a long time.

Re: Headless mode in Firefox

#90
post #53
post #17

Earlier quoted context omitted.

You can generate pdfs with headless Chromium/Chrome pretty easily[1]. chromium-browser --headless --disable-gpu --print-to-pdf=output_file_name.pdf file:///path/to/your/html [1] https://developers.google.com/web/updates/2017/04/headless-c...

If only browsers supported creation of page headers and footers.

True - but you can get them to output to PDF, then composite/stamp this pdf onto a PDF with headers/footers/whatever on it. This is very easy to do with pdftk.
Post reply on HN