Open rodrigo1406 opened 1 year ago
Adding manual page breaks solved the issue:
$cells = '';
$n = 0;
while ($n < 100) {
if (++$n % 2 == 1) {
$cells .= "<tr><td>Cell $n</td>";
} else {
$cells .= "<td>Cell $n</td></tr>";
}
if ($n % 18 == 0) {
$pdf->writeHTML("<table border=\"1\" style=\"line-height:3cm;\">$cells</table>", true, false, true, false, '');
$pdf->AddPage();
$pdf->SetMargins(10, 10, $keepmargins=true);
$pdf->SetAutoPageBreak(TRUE, 10);
$cells = '';
}
}
if ($cells) {
$pdf->writeHTML("<table border=\"1\" style=\"line-height:3cm;\">$cells</table>", true, false, true, false, '');
}
https://stackoverflow.com/questions/76917804/how-to-guarantee-tcpdf-table-will-have-equal-row-heights-across-multiple-pages
I need to create a PDF downloadable file with PHP. I'm using TCPDF, but when the table span multiple pages, the last row in each page does not have the same size as the others.
Sometimes it's shorter:
Sometimes it's taller:
Only in the last page (where it doesn't come close to the end of the page), the last row has the same height as the other rows.
Minimum reproducible version of my code:
How can I guarantee that all the rows will have exactly the same height?