8

我是 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

我的代码是

            $pdf->AddPage();
            $pdf->SetFont('Arial','B',14);
            $pdf->FancyTable($result);
            $pdf->Output();

请帮助我如何解决这个问题。谢谢

4

3 回答 3

23

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

    require_once("fpdf.php");
    class pdf extends FPDF
    {
      function __construct()
       {
          parent::FPDF();
       }
    }
于 2013-01-07T07:12:11.737 回答
4

那是因为您调用了 fpdf 库的构造函数,将 fpdf 库函数(参数)更改为 __ 构造(参数),然后将其从文件中传播。示例:文件:genpdf.php

<?php 
include('fpdf.php');
class Genpdf extends Fpdf{
    public function __construct()
    {
       parent::__construct();
    }
    public function build()
    {
       $this->AddPage();
       $this->SetFont('Arial','B',16);
       $this->Cell(40,10,'¡Hola, Mundo!');
       $this->Output();
    }
}
于 2013-11-13T01:36:56.690 回答
1

尝试删除 $pdf->FancyTable($rs); 行 并检查您是否收到 PDF。

于 2013-01-04T05:17:01.300 回答