I would like to create an html footer with tcpdf. I found this documentation to create a custom footer: https://tcpdf.org/examples/example_003/
But I have no idea how I can realize it with this html content:
<table class="tblFooter" cellpadding="5">
<tr>
<td>
Box 1
</td>
<td>
Box2
</td>
<td>
Box3
</td>
</tr>
</table>
Can you help me please? Thank you very much :)
CodePudding user response:
You have to extend the TCPDF class to add custom Header-Footer. Providing an example for your reference.
class MYPDF extends TCPDF {
public function Header() {
$hdrhtml ='
<br /><br />
<table border="0" width="650" cellspacing="1">
<tr>
<td align="center">
<br />
<font style="font-size: 10px;"><b>Some text<br /></b></font>
<font style="font-size: 10px;">Some Text</font>
</td>
</tr>
</table>
';
$this->writeHTML($hdrhtml, true, false, true, false, '');
}
public function Footer() {
$fhtml = '
<table class="tblFooter" cellpadding="5">
<tr>
<td>
Box 1
</td>
<td>
Box2
</td>
<td>
Box3
</td>
</tr>
</table>
';
$this->writeHTML($fhtml, true, false, true, false, '');
}
}
$pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins, left-top-right
$pdf->SetMargins(20, 10, 10);
// remove default header/footer
//$pdf->setPrintHeader(false);
//$pdf->setPrintFooter(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 50);