mohan
mohan

Reputation: 453

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

Upvotes: 9

Views: 28700

Answers (4)

Hardik Solanki
Hardik Solanki

Reputation: 1

Changing the PHP version to 7.4 worked for me

Upvotes: 0

Joe Black
Joe Black

Reputation: 41

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();
    }
}

Upvotes: 4

user1423506
user1423506

Reputation:

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();
       }
    }

Upvotes: 24

medina
medina

Reputation: 8187

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

Upvotes: 1

Related Questions