There is a widget for that. See the print screen to PDF: https://marketplace.mendix.com/link/component/27069
Regards,
Ronald
This link is better for creating custom pdf documents: https://docs.mendix.com/refguide/creating-your-own-documents
You first need to create a document template in which you can set the format of your document.
Take a look at the following documentation