Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page break for long table

I have a long table which shows rows on several pages. When a page ends, the row is printed half on one page and half on the next page. How can I make sure that the rows is printed completely on the new page?

like image 676
John Avatar asked Mar 21 '16 11:03

John


1 Answers

CSS property: page-break-inside: avoid; on HTML tr element does it.

Tested with:
wkhtmltopdf 0.12.3 provided for Linux (Ubuntu Trusty) 32-bit / 64-bit built on Ubuntu 14.04.2 as provided at: http://wkhtmltopdf.org/downloads.html#stable

A quick and dirty test may look like:

<tr style="page-break-inside: avoid;">
  <!-- A little border to see the result more easily -->
  <td style="border: solid 1px blue;">
    Large text possibly displayed on several pages ... 
    Large text possibly displayed on several pages ... 
    Large text possibly displayed on several pages ... 
    Large text possibly displayed on several pages ... 
  </td>
  <td>col2</td>
  <td>col3</td>
</tr>

Mozilla Developer Network page-break-inside description

like image 192
Patrick Refondini Avatar answered Oct 26 '22 19:10

Patrick Refondini