Ankit Mittal Ankit Mittal - 1 year ago 133
CSS Question

avoid page break inside row of table

I want to avoid page break inside row of table in html, when I convert html to PDF by wkhtmltopdf. I use page-break-inside:avoid with table- its works, but I have so many rows,
then not work.
If set display of tr as block or some thing else then it change the formatting of table and insert double border.
Or it is possible to insert the table header on each page, where the table was splitted.

Answer Source

You might try this with CSS:

<table class="print-friendly">
 <!-- The rest of your table here -->

    table.print-friendly tr td, table.print-friendly tr th {
        page-break-inside: avoid;

Most CSS rules don't apply to <tr> tags directly, because of exactly what you pointed out above - they have a unique display style, which doesn't allow for these CSS rules. However, the <td> and <th> tags within them usually do allow this kind of specification - and you can easily apply such rules to ALL child-<tr>'s and <td>'s using CSS as shown above.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download