marcos marcos - 1 year ago 57
PHP Question

FPDF function control

I'm new to programming and I'm creating a pdf with FPDF(A PHP Class). At the bottom of my code you will notice that I create a new page and call the function Header(). For some reason, the header is also applied to the first page. How do I only apply the header to the second page?

Here is a link to a live version of the pdf:


// classes
class PDF extends FPDF
function Logo(){
//change name of function
function HeaderOne($xCor, $yCor, $text)
//Add bottom border
function BorderLine()
$this->Rect(1, 10, 6.5, .015, 'F');
function Footer()
// Go to 1.5 cm from bottom
// Select Arial italic 8
// Print centered page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'R');
function Header(){
// Subtitle
// Line
$this->Rect(1, .5, 6.5, .015, 'F');

//pdf document preferences
$pdf = new PDF('p', 'in', 'Letter');

//Page 1
$pdf->Rect(1, 1, 6.5, .25, 'F');
$pdf->HeaderOne(1,9,'Innovation Readiness Assessment');

//Page 2

// Close and output file to the browser


Answer Source

See the official documentation for Header() and AddPage().

The AddPage() function already internally calls Header(). There is no need to call Header() explicitly here.