问题描述
我有一个由其他人完成的应用程序,现在我被要求研究一个问题.
生成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错误:无法包括字体公制文件仍在那里. 搜索网时可能的原因是
-
字体目录缺少
-
没有字体文件的访问权限.
我不确定要授予字体文件夹或文件夹中的文件的权限. 在这方面的任何帮助都会有很大的帮助.
推荐答案
我也有同样的问题.问题是通路对所有字体的文件夹是不正确的.因此,我在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并准备就绪!
问题描述
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
font directory missing
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
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!