Page break for long table

…衆ロ難τιáo~ 提交于 2020-12-08 06:42:30

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/36129306/page-break-for-long-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!