Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fpdf: header not working in fpdf

Tags:

php

fpdf

I have consumed fpdf library and using it according the official documentation from fpdf.

I want to use header in my file but not able to use that, below is my code for same. Please correct my mistake why header is not coming..

Here is my code:

<?php

require('fpdf/fpdf.php');

class PDF extends FPDF
{
function Header()
{
    // Select Arial bold 15
    $this->SetFont('Arial','B',5);
    // Move to the right
    $this->Cell(80,'ddd');
    // Framed title
    $this->Cell(30,10,'Title',1,0,'C');
    $this->Cell(20,10,'Title',1,1,'C');
    // Line break
    $this->Ln(20);
}
}

$pdf=new FPDF();

$pdf->AddPage();
$pdf->SetFont('Times','B',14);

$pdf->Cell(20,10,'Title',1,1,'C');
$pdf->Output();
?>
like image 976
Archit Avatar asked Feb 08 '23 06:02

Archit


1 Answers

Per PetrHejda's comment, all you should need to do is change

$pdf=new FPDF();

to

$pdf=new PDF();
like image 110
sql_dru Avatar answered Feb 10 '23 11:02

sql_dru