我试图抓住FPDI来结合PDF。一直在尝试setasign给出的示例代码。
FPDF - fpdf.php来自fpdf.org,v1.81 Fpdi - 我从setasign,v2beta2
获取了src<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
use \setasign\Fpdi;
// require_once('fpdf/fpdf.php');
// require_once('fpdi2/src/autoload.php');
require_once('fpdf181/fpdf.php');
require_once('fpdf181/fpdi/autoload.php');
// initiate FPDI
$pdf = new Fpdi\Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("projects/78/78_timesheet.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->useImportedPage($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();
$dir = "reports/";
$file = 'test.pdf';
$dir_file = $dir.$file;
$pdf->Output($dir_file,'F');
?>
代码不会创建任何PDF。 当我改变$ pdf = new Fpdi \ Fpdi(); to $ pdf = new FPDF();它显示一个错误: PHP致命错误:在第19行的testpdfgen.php中调用未定义的方法FPDF :: setSourceFile()
我在这里做错了什么?