简体   繁体   English

FPDF 错误 - 无法在 PDF 上显示图像

[英]FPDF Error - Can't get image to appaear on PDF

I have a PDF with fillable forms.我有一个带有可填写表格的 PDF。 I can successfully fill the forms and save the new PDF to my server no problem, but I cannot place an image on the PDF.我可以成功填写表格并将新的 PDF 保存到我的服务器,没问题,但我无法在 PDF 上放置图像。 When I remove the Image(....) line the script works great.当我删除 Image(....) 行时,脚本运行良好。 When I add it back it I get the error.当我把它加回来时,我得到了错误。

I think it's trying to look for the method in the wrong file, originally I only included fpdm..php but I tried adding back fpdf.php and it did not help.我认为它试图在错误的文件中查找该方法,最初我只包含 fpdm..php 但我尝试添加回 fpdf.php 并没有帮助。 Not sure what I'm doing wrong.不知道我做错了什么。

Error: Fatal error: Call to undefined method FPDM::Image() in /home/.../formPDF.php on line 113错误:致命错误:在第 113 行调用 /home/.../formPDF.php 中未定义的方法 FPDM::Image()

Code:代码:

require('../forms/pdf/fpdf.php');
require('../forms/pdf/fpdm.php');

$pdf = new FPDM($formPDFLocation);


$pdf->Image('images/sig_37-1405313221.png', 100, 20);
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();

$filename= "../forms/generated/" . $ffID;
$pdf->Output($filename.'.pdf','I');

FPDM is not really related to FPDF but simply a script of a FPDF user. FPDM 与 FPDF 并不真正相关,而只是 FPDF 用户的脚本。 You cannot use FPDF methods on an FPDM instance.您不能在 FPDM 实例上使用 FPDF 方法。

If you search for an all in one solution for such task you may take a look at the SetaPDF-FormFiller component (not free!).如果您搜索此类任务的多合一解决方案,您可以查看SetaPDF-FormFiller组件(不是免费的!)。

I was able to save the PDF to my server and then add the image but lost the form contents.我能够将 PDF 保存到我的服务器,然后添加图像但丢失了表单内容。 Code for anyone that is interested in this half solution:任何对此半解决方案感兴趣的人的代码:

Code for adding image:添加图片的代码:

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

$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("16.pdf");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);

 $pdf->Image('car.jpg',20,100);

$pdf->Output();

?>

我也遇到了同样的问题,您解决了吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM