gbvisconti
gbvisconti

Reputation: 412

Dynamic Footer MPDF

I'm using mdpf and php to generate a 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?

Upvotes: 0

Views: 1662

Answers (1)

user4244477
user4244477

Reputation:

You need to flush the content with WriteHTML, then set a new footer.

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

Upvotes: 1

Related Questions