【问题标题】:Class 'setasign\Fpdi\FpdfTpl' not found找不到类“setasign\Fpdi\FpdfTpl”
【发布时间】:2018-04-29 00:30:00
【问题描述】:

我正在使用 fpdf 和 fpdi 的每个人都是我的第一份工作,但我遇到了问题。我无法编辑 pdf。这就是问题。谢谢

C:\wamp\www\Ale\fpdi\src\Fpdi.php 中找不到类setasign\Fpdi\FpdfTpl

    use setasign\Fpdi\Fpdi;

require_once('fpdf/fpdf.php');
require_once('fpdi/src/Fpdi.php');
require_once('fpdi/src/autoload.php');

// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile('documento.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at position 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('newDoc.pdf','F');

【问题讨论】:

    标签: php fpdf fpdi


    【解决方案1】:

    You cannot edit a PDF with FPDI!

    删除线:

    require_once('fpdi/src/Fpdi.php');
    

    ...给后面需要的自动加载功能一个机会。

    【讨论】:

    • 我做了但仍然没有工作..这是新的错误 Class 'setasign\Fpdi\Fpdi' not found in C:\wamp\www\Ale\index.php
    • 奇怪的是当我在家里尝试代码时,工作正常。也许是针对 PHP 的版本?我正在使用 5.4.3
    • 您应该紧急升级您的 PHP 环境到最新版本! FPDI 2.x 在 PHP 5.6 及更高版本上进行了测试。
    猜你喜欢
    • 2018-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-08
    相关资源
    最近更新 更多