简体   繁体   English

中断页后的mpdf下一页标题文本应更改

[英]mpdf after break page next page header text should be change

hello please check pdf sample, I'm using mpdf to generate a pdf document in php. 您好,请检查pdf示例,我正在使用mpdf在php中生成pdf文档。

I got this pdf generated by the code below. 我得到了下面的代码生成的PDF

1st copy is perfect, but second copy of 1st page top header title show wrong i want to 2nd copy on header $title2 第一个副本是完美的,但是第一页顶部标题的第二个副本显示错误,我想在标题$title2上进行第二个副本

Can you help me? 你能帮助我吗?

<?php
include('mPDF/mpdf.php');
$mpdf = new mPDF('c', 'A4', '9', '', '10', '18', '55', '50', '50', '12', 'P');
$html = '

    <html>
    <head>
    </head>
    <body>';

for ($i = 1; $i < 80; $i++) {
    $html .= '<div>Here is the text of the first chapter</div>';
}
$html .= '</body>
    </html>';

$title1 = "<p style='text-align:right; margin:0px; font-size:15px;'>ORIGINAL </p>";
$title2 = "<p style='text-align:right; margin:0px; font-size:15px;'>DUPLICATE</p>";
$title3 = "<p style='text-align:right; margin:0px; font-size:15px;'>TRIPLICATE</p>";


$mpdf->SetHeader($title1 . $header);
$mpdf->SetFooter($footer . 'Page No. {PAGENO} of {nbpg}');
$mpdf->WriteHTML($html);
$mpdf->SetFooter($footer . 'Page No. {PAGENO} of {nbpg}');

$mpdf->WriteHTML('<pagebreak resetpagenum="1" pagenumstyle="1" suppress="" />');

$mpdf->SetHeader($title2 . $header);
$mpdf->SetFooter($footer . 'Page No. {PAGENO} of {nbpg}');
$mpdf->WriteHTML($html);
$mpdf->SetFooter($footer . 'Page No. {PAGENO} of {nbpg}');
$mpdf->Output();

PDF Sample PDF样本

According to the documentation the SetHeader function can take three parameters, the third of which is $write. 根据文档SetHeader函数可以采用三个参数,其中第三个是$ write。

This third parameter forces the Header to be written immediately to the current page. 第三个参数强制将页眉立即写入当前页面。 Use it if the header is being set after the new page has been added. 如果在添加新页面后设置了标题,请使用它。

Change to: 改成:

$mpdf->SetHeader($title2 . $header, [], true);

and it should allow the second header to be seen. 并且应该允许看到第二个标头。

You may also want to look at AddPage() . 您可能还想看看AddPage()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM