php-tcpdfHow do I set footer data using PHP TCPDF?
To set footer data using PHP TCPDF, first we need to create a new TCPDF instance by passing the page size, orientation and unit.
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
Then we need to set the PDF's page margins.
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
After that, we can set the header and footer by using the setHeaderData()
and setFooterData()
methods.
// set header data
$pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING);
// set footer data
$pdf->setFooterData(array(0,64,0), array(0,64,128));
The setHeaderData()
and setFooterData()
methods take two parameters. The first parameter is an array of RGB values for the background color. The second parameter is an array of RGB values for the text color.
Finally, we can set the font for the footer data.
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
Helpful links
More of Php Tcpdf
- How do I install TCPDF using Yum on a PHP server?
- How do I add a watermark to PDFs using PHP and TCPDF?
- How can I generate a PDF from XML data using PHP and TCPDF?
- How do I use the setfont function in PHP TCPDF?
- How can I use PHP and TCPDF to read a PDF?
- How do I install TCPDF with Composer in a PHP project?
- How can I use TCPDF's writeHTML() function in PHP?
- How do I use the setxy function in PHP TCPDF?
- How can I generate a PDF from data stored in a MySQL database using TCPDF and PHP?
- How can I generate a QR code using PHP and TCPDF?
See more codes...