I’m trying to use the writeHTML script (here: http://www.fpdf.org/en/script/script41.php) as well as the header and footer from tutorial 6 (here: http://www.fpdf.org/en/tutorial/tuto2.htm).
My code looks like this:
<?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();
?>
I’m getting the following error:
Call to undefined method PDF::WriteHTML() in /path/to/test2.php on line 15
What am I missing here?
You need to extend
PDF_HTML, notFPDFasWriteHTMLis part ofPDF_HTML.If you want inheritance to work, you always need to extend the classes you want to use. Let say you want to extend
PDF_Index, you still needWriteHTMLin the inheritance somewhere.Perhaps
and
Or,
But you need both in the chain to make it work.
If you don’t put both in the inheritance chain, then you will not use the available functions from the branch you are not using.
The, the function in PDF_HTML will not be available to PDF