Php – Using FPDF error with font helveticab.php

fpdfPHP

Im attempting to use FPDF, on Windows and using the XAMPP server.

I keep running into this error:

Warning: include(helveticab.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\php\PEAR\fpdf.php on line 541

Warning: include() [function.include]: Failed opening 'helveticab.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\php\PEAR\fpdf.php on line 541
FPDF error: Could not include font metric file

Anyone have an idea of how this can be resolved?

Also, I have checked and helveticab.php is installed which is the answer given in similar questions that i looked at.

Thanks

Best Answer

Not sure why they did it, but if the font is "Arial" they change the font to Helvetica. One of the styles is "c". They append the style to the font, so it searches and adds the fonts and styles. Example is helvetica bold is helveticab, or helvetica italic bold is helveticabi, but helveticac does not exist. To circumvent this, I added the following lines in fpdf.php at around line 498. If the style is "c", we set the style to "": Code the already have

// Test if one of the core fonts
    if($family=='arial')
        $family = 'helvetica';

Code I added:

if(stripos($style, "c")!==false)
    $style='';
Related Topic