News for hackers. Stuff that matters.
Re:URL to PDF Microservice by Scarbutt on Thursday October 05, 2017 @11:00AM (#15409691)
You need to fire a new chrome headless process every time you create a PDF, its not scalable but it works.

I wonder if this part of chrome could be easily extracted as a C++ library.

Re:URL to PDF Microservice by mrskitch on Thursday October 05, 2017 @04:33PM (#15412375)
You can actually reuse a running instance and create a new context with this: https://chromedevtools.github.io/devtools-protocol/tot/Targe.... Issue is that most libraries don't have an API for this (not sure why), and that long-running Chrome instances can get to a quirky state + other issues. Certain parameters require you start Chrome with the right flags, so reusing a running Chrome process doesn't always work.
Re:URL to PDF Microservice by zbentley on Thursday October 05, 2017 @11:40AM (#15410041)
I suspect that "extracting" this part of chrome into a library would result in the same thing: a library that starts up the full chrome environment and prints a page to PDF.

The PDF-ization isn't the part that's hard to extract (there are libraries to create PDFs from scratch already available, and they're small/intelligible). Rather, it's the rendering of a webpage for display that's the hard part, and what most of the code in any web browser is concerned with. Whether that display is a monitor or a PDF doesn't change much.

Re:URL to PDF Microservice by aidos on Thursday October 05, 2017 @01:51PM (#15411048)
I've looked and it's not easy. There are different ways you can wrap the internals of chrome but really, it's hard to (and officially not recommended, from memory) pull out just a subset to work with.