我想在我的localhost中设置FPDI,但它给了我一个错误。
Fatal error: Class 'FPDF' not found in C:\wamp\www\book\fpdf_tpl.php on line 20
这就是我所做的:
我去了download page,我下载了2包(FPDF_TPL和FPDI)并将它们解压缩到我的localhost中。
然后我做了example page:
<?php
require_once('fpdf.php');
require_once('fpdi.php');
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("PdfDocument.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 10, 10, 100);
// now write some text above the imported page
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
pdf->Output();
我做了该网站所说的内容,但我遇到了错误:
Fatal error: Class 'FPDF' not found in C:\wamp\www\book\fpdf_tpl.php on line 20
我搜索了错误代码,但我无法弄明白。
FPDI有经验吗?
答案 0 :(得分:2)
您必须在页面Download中下载该库并将其解压缩到您的文件夹中。然后代码应该工作。确保为require_once
添加了正确的路径。
答案 1 :(得分:1)
从http://www.fpdf.org/en/download.php下载fpdf库,
使用最新版本的fpdf17: require_once( 'your_dir / fpdf17 / fpdf.php');
答案 2 :(得分:0)
将以下行添加到作曲家中。
"require": {
"setasign/fpdi-fpdf": "1.6.1"
}
并使用以下代码更新作曲家。
composer update setasign/fpdi-fpdf
删除您需要的功能线并添加以下行。你会得到一个输出。
include 'vendor/autoload.php';