[英]FPDF error: Could not include font definition file in PHP
我有一堆圖像,我想生成所有這些圖像的PDF。 我正在使用FPDF
庫(1.7版)來實現此目的。 但是我收到以下錯誤:
FPDF error: Could not include font definition file
我在Google上找到了一些有關此錯誤的文章,並嘗試過但仍然存在問題。
這里應該是什么問題? 我要去哪里錯了?
我有一個類似的錯誤,我在這里分享是因為沒有在線文檔。
“ FPDF錯誤:找不到字體文件”
如果您下載了所需的文件(file.php,file.afm,file.z)后,如果使用在線實用程序( http://fpdf.fruit-lab.de )將ttf字體文件轉換為在FPDF中使用,您必須:
1)放入字體文件夾(或任何其他文件夾,但您應使用此指令define('FPDF_FONTPATH','yourpath/yourfolder/');
) define('FPDF_FONTPATH','yourpath/yourfolder/');
2)如果重命名文件,則應打開file.php並搜索包含$ .z文件名的“ $ file”並正確重命名。
也許為時已晚,但是我曾經遇到過同樣的問題,解決方案是簡單地授予對/ 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);
?>
在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);
這樣可以解決您的問題。
我遇到了這種問題,我的問題是我使用的是Linux Web服務器,並且在對字體文件的引用中未使用正確的大小寫而犯了一個錯誤。 將“ Arial”更改為“ arial”后,問題得到解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.