FPDF错误。无法在PHP中包含字体定义文件[英] FPDF error: Could not include font definition file in PHP

本文是小编为大家收集整理的关于FPDF错误。无法在PHP中包含字体定义文件的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我有很多图像,我想生成所有这些图像的PDF.我正在使用FPDF库(1.7版)来实现此目标.但是我收到以下错误:

FPDF error: Could not include font definition file

我在Google上找到了有关此错误的一些文章,并尝试了这一点,但仍然存在问题.

这里应该有什么问题?我出错了哪里?

推荐答案

我也有类似的错误,我在这里分享,因为在线没有文档.

" fpdf错误:未找到字体文件"

如果您将TTF字体文件转换为在线实用程序中在FPDF中使用( http://fpdf.fruit.fruit.fruit.fruit. -lab.de )一旦您下载了所需的文件(file.php,file.afm,file.z) 您必须:

1)放入字体文件夹(或任何其他文件夹,但您应该使用此指令define('FPDF_FONTPATH','yourpath/yourfolder/');)

2)如果您重命名文件,则应打开文件.

其他推荐答案

也许太晚了,但是我曾经有相同的问题,解决方案就是简单地给/font/文件夹给予权限...

新秀错误... 755权限为我带来了技巧.

其他推荐答案

    define('FPDF_FONTPATH','font/');



check in above line for correct path from local folder to server.....
exactly it runs well

    define('FPDF_FONTPATH','font/');

require('fpdf.php');
class PDF extends FPDF
{
//Constructor (mandatory with PHP3)
function PDF()
{
     self::__construct();
}

public function __construct()
    {
        $this->FPDF();
    }


//Page header
function Header()
{
    //Logo
    //$this->Image('logo_pb.png',10,8,33);
    //Arial bold 15
    $this->SetFont('Arial','B',15);
    //Move to the right
    $this->Cell(80);
    //Title
    $this->Cell(30,10,'Title',1,0,'C');
    //Line break
    $this->Ln(20);
}

//Page footer
function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',8);
    //Page number
    $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
}
echo "<br/>";
//Instanciation of inherited class
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Times','',12);

$pdf->Image('logo_pb.png',40,20,33);

$url="demo/ivv/doc.pdf";

$dir='C:/xampp/htdocs/laravel/public/pdf/';

$filename= time().'.pdf';

$content=$pdf ->Output($dir.$filename);

?>

本文地址:https://www.itbaoku.cn/post/2090891.html

问题描述

I have bunch of images and I want to generate PDF of of all those images. I am using FPDF library (version 1.7) for achieving this. But I am getting the following error:

FPDF error: Could not include font definition file

I found some articles on google regarding this error and tried that but still problem persist.

What should be the problem here? Where I am going wrong?

推荐答案

I had a similar error and i share here because there is no documentation online.

"FPDF error: Font file not found"

If you convert a ttf font file for use it in FPDF with the online utility (http://fpdf.fruit-lab.de) once you have downloaded the files you need (file.php, file.afm, file.z) you'll have to:

1) put in font folder (or any other folder, but you should use this instruction define('FPDF_FONTPATH','yourpath/yourfolder/');)

2) If you RENAME the files, you should open the file.php and search for "$file" which contains the name of the ".z" file and rename it properly.

其他推荐答案

Maybe a bit too late, but I used to have that same problem and the solution was to simply give permissions to the /font/ folder...

Rookie mistake... 755 permissions did the trick for me.

其他推荐答案

    define('FPDF_FONTPATH','font/');



check in above line for correct path from local folder to server.....
exactly it runs well

    define('FPDF_FONTPATH','font/');

require('fpdf.php');
class PDF extends FPDF
{
//Constructor (mandatory with PHP3)
function PDF()
{
     self::__construct();
}

public function __construct()
    {
        $this->FPDF();
    }


//Page header
function Header()
{
    //Logo
    //$this->Image('logo_pb.png',10,8,33);
    //Arial bold 15
    $this->SetFont('Arial','B',15);
    //Move to the right
    $this->Cell(80);
    //Title
    $this->Cell(30,10,'Title',1,0,'C');
    //Line break
    $this->Ln(20);
}

//Page footer
function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',8);
    //Page number
    $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
}
echo "<br/>";
//Instanciation of inherited class
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Times','',12);

$pdf->Image('logo_pb.png',40,20,33);

$url="demo/ivv/doc.pdf";

$dir='C:/xampp/htdocs/laravel/public/pdf/';

$filename= time().'.pdf';

$content=$pdf ->Output($dir.$filename);

?>