MPDF添加页面中断嵌套表

时间:2019-05-16 08:20:01

标签: php html css mpdf

我需要在MPDF的嵌套表中添加一个分页符吗?

这适用于单表分页符(多页)。

        <?php
        $html='<table  border="1" width="100%" cellpadding="0" cellspacing="0">
                <tbody>
                <tr>
                <td width="20" align="center"><strong>No</strong></td>
                <td style="min-width:300px" align="center"><strong>Name</strong></td>
                <td width="100" align="center"><strong>Qty</strong></td>
                <td width="100" align="center"><strong>Unit Price</strong></td>
                </tr>';
                for($i=1;$i<=70;$i++){
            $html.='  <tr>
                    <td align="center" ><strong>'.$i.'.</strong></td>
                    <td align="left"><strong>CAR MAINTENANCE</strong><br></td>
                    <td align="center">12.00</td>
                    <td align="center">1,000.00</td>
                    </tr>';
                     }
        $html .=' </tbody></table>';

        include("mpdf60/mpdf.php");
        $mpdf=new mPDF();

        $mpdf->SetDisplayMode('fullpage');

        $mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list

        $html1=mb_convert_encoding($html, 'UTF-8', 'UTF-8');

        $mpdf->WriteHTML($html1);

        $mpdf->Output();

        exit;

输出屏幕截图:enter image description here

但是,在使用嵌套表时,此方法不起作用

        <?php
        $html='<table  border="1" width="100%" cellpadding="0" cellspacing="0">
                <tbody>
                <tr>
                <td>

          <table  border="1" width="100%" cellpadding="0" cellspacing="0">
                <tbody>
                <tr>
                <td width="20" align="center"><strong>No</strong></td>
                <td style="min-width:300px" align="center"><strong>Name</strong></td>
                <td width="100" align="center"><strong>Qty</strong></td>
                <td width="100" align="center"><strong>Unit Price</strong></td>
                </tr>';
                for($i=1;$i<=70;$i++){
            $html.='  <tr>
                    <td align="center" ><strong>'.$i.'.</strong></td>
                    <td align="left"><strong>CAR MAINTENANCE</strong><br></td>
                    <td align="center">12.00</td>
                    <td align="center">1,000.00</td>
                    </tr>';
                     }
        $html .=' </tbody></table>
        </td></tr>
        </tbody></table>';

        include("mpdf60/mpdf.php");
        $mpdf=new mPDF();

        $mpdf->SetDisplayMode('fullpage');

        $mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list

        $html1=mb_convert_encoding($html, 'UTF-8', 'UTF-8');

        $mpdf->WriteHTML($html1);

        $mpdf->Output();

        exit;

输出屏幕截图:enter image description here

我还需要在主表td内进行分页以中断页面(如果有大量嵌套表数据),而在嵌套表tr内则需要分页(同时,单个表可以正常工作!)

0 个答案:

没有答案