未定义的字体:在Fpdf中

moh*_*han 7 php database pdf smarty fpdf

我是Fpdf库的新手,我需要在smarty中从数据库创建一个pdf.我已检查数据库中的数据是否正常,当传递字体名称时显示以下错误

Warning: in_array() expects parameter 2 to be array, null given in /var/www/html/irmt/library/class/fpdf/fpdf.php on line 526
<b>FPDF error:</b> Undefined font: helvetica B
Run Code Online (Sandbox Code Playgroud)

我的代码是

            $pdf->AddPage();
            $pdf->SetFont('Arial','B',14);
            $pdf->FancyTable($result);
            $pdf->Output();
Run Code Online (Sandbox Code Playgroud)

请帮帮我怎样才能解决这个问题.谢谢

小智 21

我认为你在pdf创建中的__construct是有问题的,试试这个

    require_once("fpdf.php");
    class pdf extends FPDF
    {
      function __construct()
       {
          parent::FPDF();
       }
    }
Run Code Online (Sandbox Code Playgroud)