I'm trying to have WKHTMLTOPDF only break a table after each tbody if necessary, never within a tbody, with each record having a tbody. I have also attempted to do this with one large tbody and somehow grouping the rows. Here is my current table code:
<table class="table" style="table-layout:fixed;" width="100%">
<thead>
<tr>
<td width="5%" class="mainheader">#</td>
<td width="19%" class="mainheader">TASK NAME</td>
<td width="57%" colspan="3" class="mainheader">HAZARDS & CONTROLS</td>
<td width="19%" class="mainheader">RISK ANALYSIS</td>
</tr>
</thead>
@foreach($tasks as $task)
@php
$TaskDate = \Carbon\Carbon::parse($task->Date)->format('Y-m-d');
$riskbefore = $task->Severity * $task->Probability;
$riskafter = $riskbefore - $task->Effectiveness;
if($riskafter == 0)
{
$riskafter = 1;
}
@endphp
<tbody>
<tr>
<td class="darkgray bigboldtext doublebottom" rowspan="3"><strong>{{ $task->TaskOrder }}</strong></td>
<td class="lightgray lfttext thickwhite" rowspan="2">{{ $task->Name }}</td>
<td class="lightgray smalllfttext thickwhite" colspan="3"><strong>Hazards:</strong> {{ $task->hazards }}</td>
<td class="darkgray thickwhite">
<text class="bigboldtext"> {{ $task->Severity }} x {{ $task->Probability }} = {{ $riskbefore }}</text></br>
<text class="smalltext"> SEVERITY PROBABILITY RISK BEFORE</text>
</td>
</tr>
<tr>
<td class="lightgray smalllfttext thickwhite" colspan="3"><strong>Controls:</strong> {{ $task->controls }}</td>
<td class="darkgray thickwhite">
<text class="bigboldtext"> {{ $riskbefore }} - {{ $task->Effectiveness }} = {{ $riskafter }}</text></br>
<text class="smalltext"> RISK BEFORE EFFECTIVENESS RESIDUAL RISK</text>
</td>
</tr>
<tr>
<td class="darkgray smalltext doublebottomwhitesides">
{{ $TaskDate }}</br>
<strong>DATE CREATED</strong>
</td>
<td class="darkgray smalltext doublebottomwhitesides">
{{ $task->SWP }}</br>
<strong>SAFE WORK PRACTICE</strong>
</td>
<td class="darkgray smalltext doublebottomwhitesides">
{{ $task->SJP }}</br>
<strong>SAFE JOB PROCEDURE</strong>
</td>
<td class="darkgray smalltext doublebottomwhitesides">
{{ $task->AF }}</br>
<strong>ADDITIONAL FORM(S)</strong>
</td>
<td class="darkgray smalltext doublebottomwhitesides">
{{ $task->OM }}</br>
<strong>OPERATORS MANUAL</strong>
</td>
</tr>
</tbody>
@endforeach
</table>
Here is the CSS that I am currently using:
tbody {
page-break-inside: avoid !important;
page-break-after:auto !important;
}
It is absolutely critical that these 3 rows stay grouped on one page. Does anybody have any ideas?