I have some code that takes some data and fills out a Thymeleaf template that then Flying Saucer turns into a pdf and it's beautiful. 🤌
The template is composed of many tables. Sometimes a table needs a variable number of rows, and the iterator can tell me that. Sometimes a table row has so wide data that the row needs another line, and that is much harder to predict (no fixed width font).
Thymeleaf is perfectly happy to chop a row in half when a page runs out of space, and put the other half on the next page. Not even at a linebreak; you can have the top of the characters on one page and the bottom on the next. This of course looks awful, so I have added some logic that roughly estimates space consumption based on table row count and makes page breaks accordingly. But, that doesn't work for wide data taking up extra lines.
The ideal solution would be that I could give certain divs an "atomic" class and make Thymeleaf act like so: If an atomic div cannot fit on the current page, make a pagebreak first. If a pagebreak was just made and an atomic div still cannot fit, do your thing and chop it off. Is there any way to accomplish this?