如何使用 FPDF/FPDI 获得精确修改后的 PDF?
我有一个任务来修改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..?
i have a task to modify the PDF and add an image into it, for which I Have used the FPDF and FPDI libraries.. whose action code is given below:
<?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");
?>
But When I get the Modified pdf I can get very distorted modified pdf... whose screen shot is given below:
The Original Document is as given below:
Hence Could anyone help me in retrieveing the correct Modified PDF using the same code/ modified code..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
其 fpdf_tpl.php 文件需要使用新下载进行更新
its fpdf_tpl.php file needed to be updated with new download
http://www.tcpdf.org/ 使用 TCPDF 其好处...
http://www.tcpdf.org/ Use TCPDF its good ...