3 ms·
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 extr
by Scarbutt 9y ago
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.
- zbentley 9y agoI 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.
- aidos 9y agoI'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.
- mrskitch 9y agoYou can actually reuse a running instance and create a new context with this: https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-createBrowserContext 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.