Since the Electron service supports posting a whole HTML blob instead of providing a URL of a page to render, we could use this to let Electron render collections.
In order to do so, we would need to generate the final HTML for the collection and send it to the electron service via POST request. How the HTML could be generated and what processing and cleaning-up is needed, is explained nicely in T142204#2557594.
What's not explicitly mentioned there, is that we would need to turn any relative URLs into absolute URLs in the HTML in order to allow Electron to download resources (e.g. images), etc.
IMO it's possible to render collections using Electron, however it would require significant amount of effort. If we are going to work on this, I suggest we add Electron support in the Collection extension or at least re-use major parts of the collection logic from the extension.
Another - and maybe even better - approach that @daniel was coming up with in our last storytime meeting:
Have a SpecialPage that generates and displays the book/collection (several articles with TOC and references) as HTML and then pass the URL to that SpecialPage to the Electron service in order to render it as PDF.
A bit more detail on the idea that Tobi just mentioned:
The special page would use a Lua module to generate wikitext for a entire book(let) from a lit of pages. Maybe it would be possible to pick a Lua module, and perhaps also a style sheet to apply. The result can then be rendered using Electron.
The Lua module provides flexibility, and allows things like a cover page and a table of contents to be added in a way consistent with how wiki pages are generally created and rendered.