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 can I use PHP and TCPDF to read a PDF?
- How can I use TCPDF's writeHTML() function in PHP?
- How do I use the setxy function in PHP TCPDF?
- How can I output a PDF file using PHP and TCPDF?
- How do I set the margins using PHP TCPDF?
- How can I use the TCPDF Multicell function in PHP?
- How can I install and use PHP-TCPDF on a Linux system?
- How to install TCPDF on Ubuntu using PHP?
- How can I add a footer to a PDF generated using PHP and TCPDF?
See more codes...