• 11

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

FPDF error: Could not include font metric file

I have a app which was done by someone else and now i am asked to look into one issue.

When a pdf report is generated it throws an error. This app uses FPDF to generate the PDF

FPDF error: Could not include font metric file

Earlier it was throwing the following error

Warning: FPDF::include(helveticab.php) [function.FPDF-include]: failed to open stream: No such file or directory 
Warning: FPDF::include() [function.include]: Failed opening 'helveticab.php' for inclusion 
FPDF error: Could not include font metric file

This was resolved by including a font folder with helveticab.php and other php files related to other fonts

But the Error FPDF error: Could not include font metric file is still there. On searching the net the possible reasons were

  1. font directory missing

  2. Doesnt have access permissions for the font files.

I am not sure what permission need to given to the font folder or files in the folder. Any help in this regard would be of great help.

I had the same issue. The issue was the path was incorrect to the folder with all of the fonts. So, I added updated the following line in the PHP file to reflect the correct path to the folder with all of the fonts.


So, double check the path that this line defines, and it should work fine.

  • 10
Reply Report
      • 1
    • On Ubuntu 10.4 the define required was: define('FPDF_FONTPATH','/usr/share/php/fpdf/font/');
    • On Debian it's also /usr/share/php/fpdf/font. And remember, if it isn't, it's because you didn't installed php-fpdf ;)

I belive you have already extracted fpdf zip file onto your localhost or system

Once, zip file is extracted you see directory structure as in below image

enter image description here

and insert the below code in test.php

//above line is import to define, otherwise it gives an error : Could not include font metric file

$pdf = new FPDF();
$pdf->Cell(40,10,'Hello World!');

Now enjoy

  • 5
Reply Report

My problem was, because of downloading the fpdf library from the page, some of the scripts they have there uses Arial font but, that font specially, was not included in the fonts directory. I just added define('FPDF_FONTPATH','fpdf/font/'); with relative path to the fpdf dir and changed font to Courier and ready!

  • 1
Reply Report

if you are using a external class that extends FPDF

like file name Custom_pdf.php

in that file you wrote your cutom codes


class Custom_PDF extends FPDF{

then you included in to your coding like

$pdf = new Custom_pdf();

this is problem...

So you directly place the code in the file you need

class Custom_PDF extends FPDF{
$pdf = new Custom_pdf();

it will works fine...


sorry for the english mistakes...

  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions