MPDF -从第一页的第10页开始编号


MPDF - Start page numbering from number 10 on the first sheet

我有一个应用程序,需要使用MPDF类打印文档,但必要时页数从43,44,45等开始。

而不是从1,2,3…

我设法从43开始,但只跳过一片叶子。我不能插入分页符。

谢谢。

下面是我的代码。

$mpdf = new mPDF();
$mpdf->setFooter("{PAGENO}");
$numero_paginas = "{nb}";
$mpdf->SetHTMLHeader('
<table>
    <tr>
        <td>
            <img src="img/cabecalho.png" />
        </td>
    </tr>
</table>
<hr>
');
$mpdf->SetHTMLFooter('');
$mpdf->WriteHTML('
<style type="text/css">
body{
    font-family:Arial, Times New Roman, sans-serif;
    font-size:10px;
}
</style>
' . $corpo_documento . '');
$mpdf->Output();
exit;

来自mPDF手册的页码:

如果您想设置从第一页开始的页码特征,您应该使用AddPage()显式地添加文档的第一页。注意,这通常不是必需的,因为mPDF在第一次使用WriteHTML()时如果需要,会自动创建一个新的第一页。

因此,在设置页脚后调用AddPage():

$mpdf = new mPDF();
$mpdf->setFooter('{PAGENO}');
$mpdf->AddPage('', '', 43);

此外,如果您通过发送参数数组来添加页面,您可以通过设置'resetpagenum' => '43'将其设置为43

$mpdf->AddPageByArray([
    'margin-left' => '15mm',
    'margin-right' => '20mm',
    'margin-top' => '25mm',
    'margin-bottom' => '15mm',
    'resetpagenum' => '43'
]);