The best way to create invoices (not just invoices) IMHO is to use an html to pdf converter. There are several API services and you can use headless chrome to do it yourself. Easy to design an invoice using a web route and simply convert it to PDF.
Especially PhantomJS whose updates tended to break the invoice formatting severely (like radically changing the rendered font size in PDF across a PhantomJS update).
Firefox required a virtual X server, but that was doable. I'd prefer to use Firefox, but unfortunately its PDF rendering screwed up the thickness of border lines, making them far too thick or not present at all, though it did a better job of pagination than Chrome.
And even having settled into using Chrome for this, there are two ways to generate a print-to-PDF that produce different results in Chrome, at least when it's Chrome on MacOS. Only one of them lays out my invoice PDFs correctly.