Reputation: 69
this is the header code, in view which is generating pdf, Even I tried to change the suspected code, still it is producing the same output..
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true,
'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Change me');
$pdf->SetTitle('Financial Report');
$pdf->SetSubject('Yearly Customer Finanacial Report');
$pdf->SetKeywords('Purchase, Sale, Order, Payment');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH,
PDF_HEADER_TITLE.' My PDF', PDF_HEADER_STRING, array(0,64,255),
array(0,64,100));
$pdf->setFooterData(array(0,64,0), array(0,64,128));
Upvotes: 2
Views: 16282
Reputation: 1890
You have to extend the base tcpdf class into Your Own and override the logo logic.
Then call new YourTcpdf()
instead.
require_once('tcpdf_include.php');
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Logo
$image_file = K_PATH_IMAGES.'logo_example.jpg';
$this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
// Set font
$this->SetFont('helvetica', 'B', 20);
// Title
$this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
}
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Change me');
$pdf->SetTitle('Financial Report');
$pdf->SetSubject('Yearly Customer Finanacial Report');
$pdf->SetKeywords('Purchase, Sale, Order, Payment');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' My PDF', PDF_HEADER_STRING, array(0,64,255), array(0,64,100));
$pdf->setFooterData(array(0,64,0), array(0,64,128));
A full example can be found here: https://tcpdf.org/examples/example_003/
Upvotes: 1