Here's an example of how to render JS-rich HTML into PDF

In case this is of use to anyone trying to figure this out. I did a lot of bashing my head on how to get a headless Chrome instance rendering downloadable PDFs and making them available via a ring handler.

I extracted it out of its production home into a (hopefully) clean example: setting up a Reagent page that includes some Vega graphs (both server- and client-rendered), driving a headless Chrome instance in a Docker container to render it to PDF, and piping the data stream to a downloadable response. All relatively straightforward in theory, but getting it working stretched my understanding of a lot of the underlying Java IO quite a bit.

Comments welcome; I’m sure there’s more I could do to production-ize it (caching, async responses, etc).

7 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.