there is a way, but it has a drawback. You can add certain CSS styling on a table (for example, a table within a template grid). The CSS you are looking for is: “page-break-inside: avoid;” (see screenshot)
This will only break a page when the contents of the table does not fit within the page, and adds a page break there and then (if the contents does fit, the page break is not added)
Here comes the drawback: if the contents of your table does not fit on a single page at all, the data will be truncated (the last part will be cut off and will not break to the next page). In an earlier project we decided to go for the page break solution (the ‘page break’ widget is not allowed in a template grid, but you can again use the css property “page-break-after: always;” on the same table in order to force the break inside a template grid…
Note that this was working in Mendix 7.9.0, but since the document template functionality has not evolved since then I highly doubt things will be different for newer projects..
The Mendix document generation functions are rather basic. If you want to do more advanced stuff, your may want to consider one of the appstore components for this, like
A simple solution is to generate a page/document per paragraph/item in a loop, put all documents in a list and after creating all pages (which are guaranteed to start with the header/title) merge the documents using MergeMultiplePdfs from the CommunityCommons app store module.
If this fits your use case however is up to you.