保留PDF表单字段



我使用FPDF/FPDI从数据库中获取PDF模板并填写数据。它工作得很好,除了一件事。PDF模板具有由最终用户填写的表单字段。问题是PDF模板被FPDF/FPDI扁平化,因此用户不能再填写文本字段。我想保留输出的PDF中的文本字段,但我不确定如何。

相关代码如下:

include('fpdf.php'); // library for PDF generation
include('fpdi.php'); // library for using FPDF with PDF templates
$pdf =& new FPDI('L','pt', 'Letter'); 
$inputPDF = 'files/templates/test.pdf';
$pdf->setSourceFile($inputPDF);
...
$pdf->AddPage();
$tplidx = $pdf->ImportPage(1); 
$pdf->useTemplate($tplidx);
$outputPDF='files/test.pdf';
$pdf->Output($outputPDF, 'F');

这在本常见问题项中描述的FPDI中是不可能的。如果你需要预填写一个PDF表单,你可以尝试SetaPDF-FormFiller组件(不是免费的!)。

最新更新