2016-04-17 39 views
2

我已經使用了fpdf庫並根據fpdf的官方文檔使用它。fpdf:header不能在fpdf中工作

我想在我的文件中使用標題,但無法使用它,下面是我的代碼相同。請糾正我的錯誤,爲什麼標題不來..

這裏是我的代碼:

<?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(); 
?> 
+2

您不是在示例代碼中的任何位置調用Header()或實例化PDF類。 – PetrHejda

回答

3

每PetrHejda的評論,你應該需要做的是改變

$ PDF =新FPDF() ;

$ pdf = new PDF();

+0

@PetrHejda如果您將您的評論添加爲答案,我會告訴OP將您標記爲已接受的答案。 –

+0

非常感謝紳士。這就是我正在尋找的.. – Archit

相關問題