FPDF错误。无法包含字体公制文件[英] FPDF error: Could not include font metric file

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

问题描述

我有一个由其他人完成的应用程序,现在我被要求研究一个问题.

生成PDF报告时会引发错误.该应用使用FPDF生成PDF

FPDF error: Could not include font metric file

早些时候它正在扔下错误

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

通过在包含helveticab.php的字体文件夹和其他与其他字体相关的PHP文件

来解决此问题.

但是错误fpdf错误:无法包括字体公制文件仍在那里. 搜索网时可能的原因是

  1. 字体目录缺少

  2. 没有字体文件的访问权限.

我不确定要授予字体文件夹或文件夹中的文件的权限. 在这方面的任何帮助都会有很大的帮助.

推荐答案

我也有同样的问题.问题是通路对所有字体的文件夹是不正确的.因此,我在PHP文件中添加了以下行,以反映所有字体的正确路径.

.

define('fpdf_fontpath','class/fpdf_font/');

因此,请仔细检查该行定义的路径,并且应该正常工作.

其他推荐答案

我相信您已经将FPDF zip文件提取到您的本地主机或系统

一次提取zip文件,您会看到目录结构,如下图中所示

在此处输入图像说明

并在test.php

中插入以下代码
<?php
define('FPDF_FONTPATH','font/');
//above line is import to define, otherwise it gives an error : Could not include font metric file
require('fpdf.php');



$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

现在享受

其他推荐答案

我的问题是,由于从页面下载了FPDF库,因此他们在那里的某些脚本使用了Arial字体,但是该字体特别不包含在字体目录中.我刚刚添加了define('FPDF_FONTPATH','fpdf/font/');的相对路径到FPDF DIR,然后将字体更改为Courier并准备就绪!

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

问题描述

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.

define('FPDF_FONTPATH','class/fpdf_font/');

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

其他推荐答案

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

<?php
define('FPDF_FONTPATH','font/');
//above line is import to define, otherwise it gives an error : Could not include font metric file
require('fpdf.php');



$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

Now enjoy

其他推荐答案

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!