开发者社区 问答 正文

使用FPDF库生成pdf时出错

我试图在PDF库的帮助下生成PDF。它给我以下错误是什么原因。

致命错误:未捕获错误:调用C:\ xampp \ htdocs \ geochronology \ library \ admin \ generatepdf1.php:26中未定义的方法FPDF :: headerTable()堆栈跟踪:#0 {main}抛出C:\ xampp \第26行的htdocs \ geochronology \ library \ admin \ generatepdf1.php

setfont('Arial','B',12); $this->cell(20,10,'SL_NO',1,0,'c'); $this->cell(20,10,'USER NAME' ,1,0,'c'); $this->cell(20,10,'AFFILIATION',1,0,'c'); $this->cell(20,10,'SAMPLE TYPE' ,1,0,'c'); $this->cell(20,10,'SAMPLE ID',1,0,'c'); $this->cell(20,10,'DATE',1,0,'c'); $THIS->Ln(); } } $pdf = new FPDF(); $pdf->AliasNbPages(); $pdf->AddPage('L','A4',0); $pdf->headerTable(); $pdf->output(); ?>

问题来源于stack overflow

展开
收起
保持可爱mmm 2019-11-15 13:59:52 531 分享 版权
1 条回答
写回答
取消 提交回答
  • 您必须调用您创建的类才能访问headeTable,因此:

    setfont('Arial','B',12); $this->cell(20,10,'SL_NO',1,0,'c'); $this->cell(20,10,'USER NAME' ,1,0,'c'); $this->cell(20,10,'AFFILIATION',1,0,'c'); $this->cell(20,10,'SAMPLE TYPE' ,1,0,'c'); $this->cell(20,10,'SAMPLE ID',1,0,'c'); $this->cell(20,10,'DATE',1,0,'c'); $THIS->Ln(); } } $pdf = new mypdf(); $pdf->AliasNbPages(); $pdf->AddPage('L','A4',0); $pdf->headerTable(); $pdf->output(); ?>
    2019-11-15 14:01:00
    赞同 展开评论
问答标签:
问答地址: