That's doable with the Python interface to GnuCash. I hacked together a little script that sucks out invoice data out of a register file and creates PDFs for new ones using a LaTeX template. My wife uses it for her business, mostly without my involvement, so seems robust enough.
teekert|2 years ago