简体   繁体   English

动态页脚MPDF

[英]Dynamic Footer MPDF

I'm using mdpf and php to generate a PDF. 我正在使用mdpf和php生成PDF。 I need to create a different footer every time I use the tag pagebreak. 每次使用标签分页符时,我都需要创建一个不同的页脚。

My code is something like this (and it's not working this way) 我的代码是这样的(并且不能这样工作)

$mpdf = new mPDF('c', 'A4');
$mpdf->SetHTMLFooter('First Article','O');
$html = 'Lots of text';
.
.
.
$html .= "pagebreak"; (this is a html tag)
$html .= 'More lots of text';
$mpdf->SetHTMLFooter('Second Article','O');

$mpdf->WriteHTML($html);
print $mpdf->Output();

How could I do that? 我该怎么办?

You need to flush the content with WriteHTML , then set a new footer. 您需要使用WriteHTML 刷新内容,然后设置一个新的页脚。

$mpdf = new mPDF('c', 'A4');
$mpdf->SetHTMLFooter('First Article','O');
$html = 'Lots of text';
.
.
.
$html .= "pagebreak"; (this is a html tag)

$mpdf->WriteHTML($html); //flush

$html .= 'More lots of text';
$mpdf->SetHTMLFooter('Second Article','O');

$mpdf->WriteHTML($html);

print $mpdf->Output();

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

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