I have encountered an architectural challenge with my server-side React app. The app renders charts and tables with page breaks in between to allow a puppeteer instance to print the report for users in another application.
The issue I'm facing is making the data printable without manual pagination. The data needs to flow seamlessly, extending until a page break is necessary, then continuing onto a new page for the next set of information. The complexity lies in the dynamic nature of the data, including varying row heights and widths.
My current approach involves measuring the table's height after each row insertion to determine if it exceeds the max height limit. If it does, a new table with a page break is initiated.
I've explored existing solutions like applying CSS page break rules but found them unsuitable due to specific requirements like custom headers and footers displaying metadata related to the content.
I have provided a sample code snippet in this CodePen, demonstrating the layout I'm trying to achieve. The footer element should appear on both printed pages and reflect the number of rows displayed per page dynamically, which eliminates the possibility of using a static footer within the table structure.
I am considering hiding the table during rendering, gradually calculating its height as rows are added to implement my initial method effectively. However, I remain open to alternative suggestions or insights from others familiar with such challenges.