- caveat 1: this is (or was) a more or less undocumented function and a few years ago it just disappeared only to come back in a later release.
- caveat 2: even though you can convert local files it does require internet access as any references to icons, style sheets, fonts and tracker pixels cause Firefox to attempt to retrieve them without any (sensible) timeout. So, running this on a server without internet access will make the process hang forever.
Last time I explored this, Firefox rendered thin lines in subtly bordered tables as thick lines, so I had to use Chromium. But back then Chrome did worse at pagination than Firefox.
So I used Firefox for multi-page documents and Chromium for single-page invoices.
I spent a lot of time with different versions of both browsers, and numerous quirks made a very unpleasant experience.
Eventually I settled on Chromium (Ungoogled), which I use nowadays for invoices.
Why, Firefox has a headless mode. It can't just print a document via a simple CLI command, you have to go for Selenium (or maybe Playwright, I did not try it in that capacity). Foxdriver would work, but its development ceased.
same: google-chrome --headless --disable-gpu --no-pdf-header-footer --hide-scrollbars --print-to-pdf-margins="0,0,0,0" --print-to-pdf --window-size=1280,720 https://example.com
ended up using headless chrome specifically to make sure javascript things rendered properly
Used this, sigh of relief, thank you
Can Chromium do this?
Edit: it appears so- https://news.ycombinator.com/item?id=15131840
Yes, routinely works for me.
Can Firefox do this?
with an elaborate script that relies on xdotool
Yes, kind of...
/path/to/firefox --window-size 1700 --headless -screenshot myfile.png file://myfile.html
Easy, right ?
Used this for many years... but beware:
- caveat 1: this is (or was) a more or less undocumented function and a few years ago it just disappeared only to come back in a later release.
- caveat 2: even though you can convert local files it does require internet access as any references to icons, style sheets, fonts and tracker pixels cause Firefox to attempt to retrieve them without any (sensible) timeout. So, running this on a server without internet access will make the process hang forever.
Last time I explored this, Firefox rendered thin lines in subtly bordered tables as thick lines, so I had to use Chromium. But back then Chrome did worse at pagination than Firefox.
So I used Firefox for multi-page documents and Chromium for single-page invoices.
I spent a lot of time with different versions of both browsers, and numerous quirks made a very unpleasant experience.
Eventually I settled on Chromium (Ungoogled), which I use nowadays for invoices.
Why, Firefox has a headless mode. It can't just print a document via a simple CLI command, you have to go for Selenium (or maybe Playwright, I did not try it in that capacity). Foxdriver would work, but its development ceased.