Suggestions for creating complex report to .pdf

I’m struggling with a fairly complex report generator, specifically header/footer placement and related, pagination. This reporter is gathering data in background tasks, and based on user selections in a modal form (alert), I include or exclude specific pages from the report.

I using anvil.pdf and calling PDFRenderer using a form as a ‘base’ form. This base form takes in two parameters, one is a dictionary with all the data, the other is a dictionary that specifies which pages should be included. The base form adds each required page to itself as components. This is all working fairly well, very well actually. However, I don’t seem to be able to control/specify page breaks. Also, placement of header/footer content on each page is not behaving the way I would expect.

Each report page is a blank panel. I start with an XYPanel thinking that my ability to place other components on this would be quite precise, however, I’m finding that when I specify very particular xy coordinates, the properties panel ‘changes’ these depending on width or something… sometimes.

I suspect I’m missing something quite fundamental, as in my entire approach to building the base or something is not quite right. Any/all ideas welcomed.

Yes, you are missing the fact that rendering HTML to PDF is always going to be an horrible experience.

I played with it a little, no, a lot, and if you are very lucky, this could help you with headers and footers: Printing to PDF with good header and footer

You can use the PageBreak from Anvil Extras.

Thanks Stefano… sigh, I’m months into this project so can’t really quit. Definitely appreciate your example, to the extent possible I’ll leverage the hours you’ve put into this as well.