我是编程新手,我正在创建一个带FPDF(PHP类)的pdf。在我的代码底部,您会注意到我创建了一个新页面并调用了函数Header()。出于某种原因,标题也应用于第一页。如何仅将标题应用于第二页?
以下是pdf实时版本的链接:http://fosterinnovationculture.com/experiments/fpdf/index-two.php
<?php
require('fpdf.php');
// classes
class PDF extends FPDF
{
function Logo(){
$this->Image('images/logo.png',1,5.5,3);
}
//change name of function
function HeaderOne($xCor, $yCor, $text)
{
$this->SetX($xCor);
$this->SetY($yCor);
$this->SetFont('Arial','B',18);
$this->Cell(5,1,$text);
}
//Add bottom border
function BorderLine()
{
$this->SetDrawColor(0,0,0);
$this->SetFillColor(0,0,0);
$this->Rect(1, 10, 6.5, .015, 'F');
}
function Footer()
{
// Go to 1.5 cm from bottom
$this->SetY(-5.7);
// Select Arial italic 8
$this->SetFont('Arial','I',8);
// Print centered page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'R');
}
function Header(){
// Subtitle
$this->SetY(.25);
$this->SetX(1);
$this->SetFont('Arial','',12);
$this->Cell(6,1,'INNOVATION READINESS ASSESSMENT');
// Line
$this->SetDrawColor(0,0,0);
$this->SetFillColor(0,0,0);
$this->Rect(1, .5, 6.5, .015, 'F');
}
}
//pdf document preferences
$pdf = new PDF('p', 'in', 'Letter');
$pdf->AddPage();
$pdf->SetMargins(1,1,1,1);
//Page 1
$pdf->SetDrawColor(238,170,40);
$pdf->SetFillColor(238,170,40);
$pdf->Rect(1, 1, 6.5, .25, 'F');
$pdf->Image('images/header.jpg',1,1.5,6.5,3.5,'JPG','');
$pdf->Logo();
$pdf->HeaderOne(1,9,'Innovation Readiness Assessment');
$pdf->BorderLine();
//Page 2
$pdf->AddPage();
$pdf->Header();
// Close and output file to the browser
$pdf->Output();
&GT;