0

I'm currently using DOMPDF and MPDF, and they work well. For some reason I prefer MPDF though support for it has pretty much dropped.

Currently I'm working on something where I need to generate a table:

<body>
<table>

<thead>
<tr><th></th><th></th><th></th></tr>
</thead>

<tbody>
<tr><td></td><td></td><td></td></tr>
</tbody>

<tbody>
<tr><td></td><td></td><td></td></tr>
</tbody>

<tbody>
<tr><td></td><td></td><td></td></tr>
</tbody>

</table>

</body>

As you will see I've got multiple tbody sections. Reason is, I need to make sure that everything within a tbody is not broken when it comes to a page break. I need those set of rows within a tbody to always appear on the same page.

I'd do this by applying the class:

.tbody {page-break-inside:avoid;}

Unfortunately DOMPDF and MPDF do not support this.

I believe wkhtmltopdf does, but the process of using composer to get it up and running and the complcation involved seems a tad bit extreme to me.

Is there a pure PHP PDF generator that could handle this?

Thanks.

StuyvesantBlue
  • 135
  • 1
  • 15
  • Try "page-break-before: always;", I had to do the exact same thing as you and this is what I used. (dompdf) – viion Feb 20 '17 at 11:39
  • Thanks. I might have been a bit unclear. I don't want to ensure every tbody goes to a new page. I just want to ensure that should a tbody end up in the middle of a break, that the entire tbody goes to the next page instead. – StuyvesantBlue Feb 20 '17 at 11:54
  • Dompdf versions up to and including 0.8.0 do not support this functionality. This doesn't resolve your current issue, but I wanted to note that support for page-break declarations on table elements will potentially be included in an upcoming release (0.8.1 or 0.9.0). – BrianS Feb 22 '17 at 23:08
  • @BrianS thanks for the update. Looking forward to the update :) In the meantime I've settled for letting the rows be separate it's not too much of an issue. – StuyvesantBlue Feb 24 '17 at 09:36

0 Answers0