[英]Using FPDF's WriteHTML() in header/footer
我试图使用的WriteHTML脚本(此处http://www.fpdf.org/en/script/script41.php )以及来自教程6(这里的页眉和页脚: HTTP://www.fpdf .org / en / tutorial / tuto2.htm )。
我的代码看起来像这样:
<?php
require_once('WriteHTML.php');
class PDF extends FPDF
{
// Page footer
function Footer()
{
$this->SetY(-30);
$this->SetFont('Arial','I',8);
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
$html = '<p>some HTML</p>';
$this->WriteHTML($html);
}
// Some more functions... header, PrintChapter etc...
}
$pdf = new PDF();
$pdf->SetTitle($title);
$pdf->AddPage();
$pdf->PrintChapter(1,'A RUNAWAY REEF','test.txt'); // print text file content
$pdf->Output();
?>
我收到以下错误:
Call to undefined method PDF::WriteHTML() in /path/to/test2.php on line 15
我在这里错过了什么?
您需要扩展PDF_HTML
,而不是FPDF
因为WriteHTML
是PDF_HTML
一部分。
如果您希望继承工作,则始终需要扩展要使用的类。 假设你想扩展PDF_Index
,你仍然需要继承WriteHTML
。
也许
PDF extends PDF_Index
和
PDF_Index extends PDF_HTML
要么,
PDF_HTML extends PDF_Index
但是你需要链中的两个才能使它工作。
如果您不将两者都放在继承链中,那么您将不会使用您未使用的分支中的可用函数。
---> PDF_HTML
/
FPDF ----> PDF_Index ----> PDF
PDF_HTML中的函数将无法用于PDF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.