gpt4 book ai didi

php - FPDF 错误 : Template does not exist! fpdf

转载 作者:可可西里 更新时间:2023-10-31 23:46:47 25 4
gpt4 key购买 nike

所以我想用 php 修改一个 pdf 模板。

我环顾四周,发现大多数人都使用 FPDI,于是我试了一下。

所以我做的是

include('pdf/fpdf.php');
include('pdf/fpdi.php');

// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the sourcefile
$pagecount = $pdf->setSourceFile('pdf/menu_blanka.pdf');
// import page 1
$template = $pdf->importPage($pagecount);
// use the imported page as the template
$pdf->useTemplate($template, 0,0,0);

而且我经常收到此错误“FPDF 错误:模板不存在!”。

你们能帮帮我吗?

最佳答案

以下是我如何在我的一个项目中实现这一目标的。工作正常..

require_once 'pdf/fpdf.php';
require_once 'pdf/fpdi.php';

$pdf = new FPDI();

$pdf->setSourceFile('/path/to/source.pdf');

$pdf->AddPage();
$tplidx = $pdf->ImportPage(1);
$pdf->useTemplate($tplidx, 0, 0, 0);

$output = $pdf->Output('output.pdf', "S");

关于php - FPDF 错误 : Template does not exist! fpdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32776623/

25 4 0