动态页脚MPDF

时间:2014-10-02 20:01:04

标签: php footer mpdf

我使用mdpf和php生成PDF。每次我使用标签分页时,我都需要创建一个不同的页脚。

我的代码是这样的(并且它没有以这种方式工作)

$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();

我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您需要使用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();