Search code examples
c#asp.net-mvcrotativapage-break-inside

Clean Page break with Rotativa pdf for asp.net MVC


I am using Rotativa to convert my HTML to PDF, I have a div that repeats itself n number of times and it has a table which can have n number of rows. I am trying to find a clean way to break the page at exact point that doesn't make half of div in one page and half in other. I have tried getting the row count and adding a page break to it after getting enough rows that can be visible in a single page without breaking the div into two pages, but that still doesn't help in some cases as the number of rows increases. And also page-break after repeating the div doesn't work. Can someone help me with allowing the page-break to work after a certain occurrence of divs.


Solution

  • At my job, when doing pdf (but not with Rotativa), we keep the available white space in the page in pixel and reduce what's left every time we add some lines. We check every time to see if there's enough space left to add the new div of lines based on the number of lines and if not, we put a page-break in the document.