Shahil Shahil - 1 month ago 8
CSS Question

Pagebreak for contents in pdf and print

I have a html which will be generated to pdf. I have few tables in that. How can i break the content to next page if the content is big ?

I have tried using the

page-break-after:always
but had no effect.

Answer

The below rules can help you add page break for tables.

   table { page-break-inside:auto }
   tr    { page-break-inside:avoid; page-break-after:auto }

Or try adding a div as:

<div class="page-break"></div>

with styles:

@media all {
    .page-break { display: none; }
}

@media print {
    .page-break { display: block; page-break-before: always; }
}
Comments