0

I am attempting to generate a PDF from a razor page HTML page, using SelectPDF. This html is a report that is dynamically generated, and as such any given table can have arbitrary number of elements in them.

Is there a way to make sure that when a table contains too many rows to fit on one page, that the table stops, inserts the pagebreak, and then starts again on the next page, instead of just continuing as if the pagebreak wasn't there?

Effectively, how do I make pagebreaks in the middle of a table look pretty?

TheJack38
  • 384
  • 1
  • 3
  • 13

2 Answers2

1

I had the same problem using the html rendering functionality, and this worked for me, but I had to use the page break style with the repeating table headers to get an acceptable result.

    <table border="1" style="page-break-inside: avoid;">
         <thead style="display: table-header-group; page: auto">
        </thead>
        <tbody>
          table code
        </tbody>

Relevant Links:

dbc
  • 104,963
  • 20
  • 228
  • 340
jblau
  • 11
  • 1
0

this link will help you SelectPDF using "page-break-before","page-break-after" or "page-break-inside".

<div style="page-break-after: always">
 A page break will be inserted AFTER this div element because "page-break-after" 
 property is set to "always".
</div>
Marwen Jaffel
  • 703
  • 1
  • 6
  • 14
  • This does not answer the question, because this will not help someone insert a pagebreak in the middle of a table. – TheJack38 Jan 27 '20 at 13:07