简体   繁体   中英

Undefined font: In Fpdf

I'm New to Fpdf library, i need to create a pdf from data base in smarty. i have checked the data from data base is fine, when pass the font name the below error was show

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

my code is

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

Please help me how can i solve this problem. thank adv

I think your __construct in the pdf creation is problem, try this one in

    require_once("fpdf.php");
    class pdf extends FPDF
    {
      function __construct()
       {
          parent::FPDF();
       }
    }

that's because you call the constructor of the fpdf library, change the fpdf library function (parameters) to __ construct (parameters), then spread it from your file. example: file : 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();
    }
}

Try to remove the line $pdf->FancyTable($rs); and check if you get the PDF.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM