2

我有一堆图像,我想生成所有这些图像的 PDF。我正在使用FPDF库(1.7 版)来实现这一点。但我收到以下错误:

FPDF error: Could not include font definition file

我在谷歌上找到了一些关于这个错误的文章并尝试过,但问题仍然存在。

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

4

6 回答 6

12

我有一个类似的错误,我在这里分享,因为没有在线文档。

“FPDF 错误:找不到字体文件”

如果您在下载所需文件(file.php、file.afm、file.z)后使用在线实用程序( http://fpdf.fruit-lab.de )转换 ttf 字体文件以在 FPDF 中使用它你必须:

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

2)如果你重命名文件,你应该打开file.php并搜索包含“.z”文件名称的“$file”并正确重命名。

于 2016-07-21T10:19:55.163 回答
5

也许有点太晚了,但我曾经遇到过同样的问题,解决方案是简单地授予 /font/ 文件夹的权限......

新手错误... 755 权限对我有用。

于 2013-07-26T12:12:52.120 回答
2
    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);

?>
于 2017-04-26T11:50:38.467 回答
1

您必须为正在使用的字体创建字体定义文件。

看这里:

http://www.fpdf.de/tutorials/7/

于 2013-07-26T10:27:50.880 回答
0

在 AddFont 函数中检查您的字体路径。

例如:

$fontInformation = pathinfo(WWW_ROOT . "files/files/font/file/" . $pdffile['font_file']);

$fontFileName = $fontInformation['filename'] . '.php';

//$pdf->fontpath = WWW_ROOT . "files/font/file/";


$pdf->AddFont($fontInformation['filename'], '', $fontFileName);

//set font for the entire document
$pdf->SetFont($fontInformation['filename'], '', 20);

这可能会解决您的问题。

于 2013-05-23T08:54:30.240 回答
0

我遇到了这种问题,我的问题是我使用的是 linux Web 服务器,我犯了一个错误,即在我的字体文件引用中没有使用正确的大小写。在我将“Arial”更改为“arial”后,问题就解决了。

于 2019-10-22T13:29:42.973 回答