分页表-在行或每个正文之后

时间:2019-01-28 16:30:59

标签: php css html-table wkhtmltopdf

我试图让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>&nbsp;{{ $task->hazards }}</td>
                                        <td class="darkgray thickwhite">
                                            <text class="bigboldtext">&nbsp;&nbsp;&nbsp;&nbsp;{{ $task->Severity }}&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;&nbsp;&nbsp;&nbsp;{{ $task->Probability }}&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;{{ $riskbefore }}</text></br>
                                            <text class="smalltext">&nbsp;&nbsp;&nbsp;SEVERITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PROBABILITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RISK BEFORE</text>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="lightgray smalllfttext thickwhite" colspan="3"><strong>Controls:</strong>&nbsp;{{ $task->controls }}</td>
                                        <td class="darkgray thickwhite">
                                            <text class="bigboldtext">&nbsp;&nbsp;&nbsp;&nbsp;{{ $riskbefore }}&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;{{ $task->Effectiveness }}&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;{{ $riskafter }}</text></br>
                                            <text class="smalltext">&nbsp;RISK BEFORE&nbsp;&nbsp;&nbsp;EFFECTIVENESS&nbsp;&nbsp;&nbsp;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行分组在一页上绝对至关重要。有人有什么主意吗?

0 个答案:

没有答案