Do you create a HTML document then print the output as a PDF with headless Chrome?
Yes exactly, HTML document using whatever templating language you want (or even client-side JavaScript framework since Chrome can handle that too) and then output a PDF.
I use currently use puppeteer to do the same thing