Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf thead overlapps content on second page

Here is how my PDF result looks like (see the overlapping header on the second page):

enter image description here


The code is a simple HTML table with lots of content inside one TD element.

<table>
  <thead>
    <tr>
      <th>BESCHREIBUNG</th>
      <th>PREIS</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Lots of TEST's</td>
      <td>1,40 EUR</td>
    <tr>
  </tbody>
</table>

I know there is already this issue (as well as some others):

wkhtmltopdf repeating thead headers overlapping content

And the solution in there works for me:

thead { display: table-header-group; }
tfoot { display: table-row-group; }
tr { page-break-inside: avoid; }

However it only works for tables with multiple rows (tr's).

In my case as you see above I have a TD with a description that can contain quite a lot of content, so one single row would span across more than one page.

Does one have a solution for this special case as well?

like image 841
JochenJung Avatar asked May 24 '18 08:05

JochenJung


1 Answers

The solution you have would work if you split your description into many pieces as a string array. And print each piece in a tr.

like image 64
Candice Avatar answered Oct 20 '22 11:10

Candice