Here's a quick way to do pdf layouts, example: invoice. In Libreoffice and save as .fodt flat XML open document. Then it's easy to do substitutions and export as PDF in code. This can be done on 'headless' server. There are libraries which do pdf's etc but I think this way speeds up layout creation, lines etc.