php - 如何使用 FPDF/FPDI 获取准确修改后的 PDF?

标签 php pdf fpdf fpdi

我的任务是修改 PDF 并向其中添加图像,为此我使用了 FPDF 和 FPDI 库。其操作代码如下:

<?php
require_once('fpdf.php');
require_once('fpdi.php');

$pdf =& new FPDI();
$pdf->AddPage();

//Set the source PDF file
$pagecount = $pdf->setSourceFile("Completed.pdf");

//Import the first page of the file
$tpl = $pdf->importPage(1);


//Use this page as template
// use the imported page and place it at point 20,30 with a width of 170 mm
$pdf->useTemplate($tpl, 20, 30, 170);

#Print Hello World at the bottom of the page

//Select Arial italic 8
$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$pdf->SetXY(90, 160);
//$pdf->Rotate(90);
$pdf->Image('think.jpg',120,240,20,20);
$pdf->Image('think.jpg',120,260,20,20);
//$pdf->Write(0, "Hello World");

$pdf->Output("modified_pdf.pdf", "F");
?>

但是当我得到修改后的 pdf 时,我会得到非常扭曲的修改后 pdf...其屏幕截图如下:

enter image description here

原文档如下:

enter image description here

因此,任何人都可以使用相同的代码/修改后的代码帮助我检索正确的修改后的 PDF 吗?

最佳答案

它的 fpdf_tpl.php 文件需要用新的下载更新

关于php - 如何使用 FPDF/FPDI 获取准确修改后的 PDF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5256153/

相关文章:

php - FPDF错误: Unsupported image type: image/jpeg

php - 使用 GET 进行 Laravel URL 过滤

php - 按多列对 MYSQL 结果进行排序

python - 如何使用 Tika 将 PDF 拆分为段落

php - 为 PDF 页面添加标题 [FPDF]

fpdf - 通过FPDI扩展TCPDF时,是否有使用交易的方法?

php - Laravel 时区设置未生效

php - 如何将产品单位与购物车摘要中的特征值相乘 Prestashop

c# - 在 C# 中以编程方式读取 PDF

android - 在 WebView 中打开 PDF 文件