I am trying to break a table row (tr) into two pages if the content doesn’t fill the page,
Now it is breaking the whole into the next page which results in blank space in the first page above the footer
I am using the WriteHTML to generate pdf content
foreach ($product_details as $prod_det) {
$rate = format_currency($prod_det->qpd_rate);
$amount = format_currency($prod_det->qpd_amount);
$disc = number_format($prod_det->qpd_discount, 2);
$pdf_data .= '
<tr nobr="false">
<td align="center" width="8%" style="padding: 2px; vertical-align: top;">' . $k . '</td>
<td align="left" width="45%" style="padding: 2px;" vertical-align: top;>' . $prod_det->product_details . '</td>
<td align="center" style="padding: 2px; vertical-align: top;" >' . $prod_det->qpd_quantity . '</td>
<td align="center" style="padding: 2px; vertical-align: top;" >' . $prod_det->qpd_unit . '</td>
<td align="right" style="padding: 2px; vertical-align: top;" >' . $rate . '</td>
<td align="center" style="padding: 2px; color:red; vertical-align: top;" ><i>' . $disc . '</i></td>
<td align="right" style="padding: 2px; vertical-align: top">' . $amount . '</td>
</tr>
';
$k++;
}
$mpdf = new MpdfMpdf([
'margin_top' => 68,
'margin_bottom' => 0,
'margin_left' => 5,
'margin_right' => 5,
'defaultfooterline' => 0,
'setAutoTopMargin' => 'stretch',
'setAutoBottomMargin' => 'stretch',
'keep_table_proportions' => false,
]);
$mpdf->simpleTables = true;
$mpdf->use_kwt = true; // Keep-with-table
$mpdf->packTableData = true; // Better table handling
$mpdf->shrink_tables_to_fit = 0; // Don't shrink tables
$mpdf->SetAutoPageBreak(true);
$mpdf->SetTitle($title);
$main_table = '<style>
th, td { padding: 4px; font-size: 12px; }
p { font-size: 12px; margin-bottom: 13px; }
table {
page-break-inside: auto;
}
tr {
page-break-inside: auto;
page-break-after: auto;
}
td {
page-break-inside: auto;
}
</style>
<table width="100%" style="page-break-inside:auto;border-collapse: collapse; margin-top: 10px;border-top:1px solid;line-height:18px;" autosize="1">
<thead>
<tr>
<th align="center" width="8%" style="border-bottom:1px solid;">Item No</th>
<th align="center" width="45%" style="border-bottom:1px solid;">Description</th>
<th align="center" style="border-bottom:1px solid;">Qty</th>
<th align="center" style="border-bottom:1px solid;">Unit</th>
<th align="center" style="border-bottom:1px solid;">Rate</th>
<th align="center" style="border-bottom:1px solid;">Disc%</th>
<th align="center" style="border-bottom:1px solid;">Amount</th>
</tr>
</thead>
<tbody>
' . $pdf_data . '
</tbody>
</table>
';
$mpdf->WriteHTML($main_table);
//Other code
tried using page-break-inside: auto style inside table,tr,tbody, putting the row inside a whole tbody, in a whole table