5 ms·
The only thing I don't understand is why browsers doesn't expose an API for this? Or whatever it sends down to the printer menu, since you can already save a pa
by hnedeotes 6y ago
The only thing I don't understand is why browsers doesn't expose an API for this? Or whatever it sends down to the printer menu, since you can already save a page as PDF?
And the same for bare pictures since the rendering engine has to have drawn all of that to display it?
Is it something to do with pdf's being Adobe's?
(I still see the utility of a command line program but just wondering since they have some issues around font-sizing, fonts loaded through the web, etc)
- andix 6y agoI tried once to use Chromium as a library to create PDF. But even they don’t expose a nice C API for that, with all the settings you can make in the UI. Super messy.
- abhinav22 6y agoPdf standard I believe is open now, or at least there is a very, very detailed guide by Adobe (I’ve read parts of it). Considering there are competing pdf readers to Adobe, this makes sense Browser pdf styling is quite good actually, I just hate the fact it prints date / web titles by default (only user can unselect) and doesn’t work that well with paged media I was thinking of building my own project in an adjacent area, so I did a lot of research. PrinceXML is my favourite, although it doesn’t work well as an integration to an app since then you have to share profits with them In the end I ditched my project (lol)
- hnedeotes 6y ago> Browser pdf styling is quite good actually It is but I remember going through so many hoops to do it, when a "browser.export_pdf()" would have been so handy. Does yours live in some repository online?
- abhinav22 6y agoUnfortunately not, I didn’t accomplish much of value in the end
- pluc 6y agoBecause the PDF standard is open doesn't mean it's good - that thing is one of the worst mess I've seen.
- tinus_hn 6y agoIs all of it open? Like the ‘3D models’, the dynamic scripting and the forms?
- jhoh 6y agoThey do. You can use something like puppeteer to use a headless Chrome or Firefox to generate PDFs from HTML for you. https://github.com/puppeteer/puppeteer/blob/v5.3.1/docs/api.md#pagepdfoptions https://github.com/puppeteer/puppeteer/blob/v5.3.1/docs/api....
- hnedeotes 6y agoYeap, I used this, but I had to setup a lambda, then get chrome in it, then use puppeteer. If this was something that you could programatically trigger from JS then you could have a button "Export to PDF" and just make a downloadable blob, because the rendering is pretty good and with css @media for print you can really make it tight.
- williamsmj 6y agoYou don't need to use pupeteer: https://developers.google.com/web/updates/2017/04/headless-chrome#create_a_pdf https://developers.google.com/web/updates/2017/04/headless-c...