In the past i have done this by overlaying a pdf with the background image.
In the community commons module there is a java action called: OverlayPdfDocument
Create the pdf with the document template and also use an ulpoaded pdf with the background image and use the java action to overlay.
For PDF you can use Maarten’s suggestion. For other documents there are some other sollutions. Here an example with templater:
Yes you need a license but it is only one time $200 from the company that creates the Java library that is used in this module.