我试图让WKHTMLTOPDF仅在必要时在每个tbody之后才打破表,而不是在tbody内,而每个记录都有一个tbody。我也尝试过用一个大的躯干并以某种方式对行进行分组。这是我当前的表格代码:
<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>
这是我当前正在使用的CSS:
tbody {
page-break-inside: avoid !important;
page-break-after:auto !important;
}
将这3行分组在一页上绝对至关重要。有人有什么主意吗?