【发布时间】:2011-07-12 11:39:48
【问题描述】:
我的任务是修改 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...其屏幕截图如下:
原始文件如下:
因此任何人都可以帮助我使用相同的代码/修改后的代码检索正确的修改后的 PDF..?
【问题讨论】:
-
@Gordan 你能帮帮我吗?
-
@Pekka 你能帮帮我吗?
-
最近遇到了同样的问题,似乎是保存到文件时 fpdf 中的一个错误 - 下载相同的生成的 pdf 作品。我最终导出为 xls 而不是 pdf。
-
字体好像损坏了,你是不是比较二进制文件?
-
@Maerlyn @p4553d 感谢关注,因为它是一个 BUG。但不幸的是,我需要获取 PDF...