Link to home
Start Free TrialLog in
Avatar of ob1_
ob1_

asked on

Getting error calling function using FPDF to create PDF file with PHP

Hi all, I am trying to create a PDF file with FPDF and I get the following error when I call the function that is used to create the table in the file: Fatal error: Call to undefined function: fancytable(). I have a function called fancytable, and then a class called FPDF that calls it.


thanks,
bob
function FancyTable($header,$data) {
 
    //Colors, line width and bold font
    $this->SetFillColor(255,0,0);
    $this->SetTextColor(255);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
    //Header
    $w=array(40,35,40,45);
    for($i=0;$i<count($header);$i++)
        $this->Cell($w[$i],7,$header[$i],1,0,'C',1);
    $this->Ln();
    //Color and font restoration
    $this->SetFillColor(224,235,255);
    $this->SetTextColor(0);
    $this->SetFont('');
    //Data
    $fill=0;
    foreach($data as $row)
    {
        $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
        $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
        $this->Cell($w[2],6,$row[2],'LR',0,'R',$fill);
        $this->Cell($w[3],6,$row[3],'LR',0,'R',$fill);
        $this->Ln();
        $fill=!$fill;
    }
    $this->Cell(array_sum($w),0,'','T');
}
 
 
$pdf=new FPDF();
//Column titles
$header=array('Day','Date','Job Code','Hours');
//Data loading
$data=$tarr;
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Weekly Timesheet');
$pdf->SetFont('Arial','',12);
$pdf->Cell(40,10, "Employee: " . $fname2 . " " . $lname2,1,0,'');
$pdf->Cell(40,10, "Week Ending: " . $wending,1,1,'');
$pdf->SetFont('Arial','',14);
$pdf->FancyTable($header,$data);
$pdf->Output();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Line 1 should read:
class FPDFExtended extends FPDF {
Avatar of ob1_
ob1_

ASKER

thanks Roonaan!