You can use my heavily used module for this. Is entirely for free and comes with a fully configured demo project:
https://marketplace.mendix.com/link/component/111539
Hi Harry,
you can use this module https://marketplace.mendix.com/link/component/2026 there is great documentation how to implement it.
So you will need to load your document template where you will have tokens that will then be modified with the information you want to have. eg in the image below from the module documentation, everything inside the « » are tokens that will be replaced by your data. Within the application, you will need to map those tokens to your objects.
I hope this will help you.
Kind regards,
Domagoj