我正在做PHP,Codeignitor。我有一个可编辑的pdf。我想填写pdf中的空白字段,如名字,姓氏,电子邮件。我在php中使用了FPDF和FPDI。首先,我包含了fpdf和fpdi文件。创建一个函数。我的代码如下。因为我创建了FPDI对象。
$pdf = new FPDI();
$pdf->AddPage();
$path = base_url().'uploads/test.pdf';
$pdf->setSourceFile($path);
// import page 1
$tplIdx = $this->pdf->importPage(1);
//use the imported page and place it at point 0,0; calculate width and height
//automaticallay and ajust the page size to the size of the imported page
$this->pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
// now write some text above the imported page
$this->pdf->SetFont('Arial', '', '13');
$this->pdf->SetTextColor(0, 0, 0);
//set position in pdf document
$this->pdf->SetXY(20, 20);
//first parameter defines the line height
$this->pdf->Write(0, 'gift code');
//force the browser to download the output
$this->pdf->Output('gift_coupon_generated.pdf', 'D');请帮帮我。
发布于 2015-11-14 05:36:34
FPDI无法处理PDF表单。表单域在导入过程中丢失,如FAQ中所述
PDF As FPDI不修改
文档,而是将其逐页导入到可与FPDF一起重复使用的结构中,页面内容流之外的所有内容,如表单字段注释,都会丢失。
无论如何,您仍然可以将文本放在导入的页面上。这只是一个手动步骤来解析字段坐标。
发布于 2017-06-15 13:35:32
您可以首先使用ghost脚本平面化文件。然后,您可以使用fpdi导入它。这是你的工作流程的另一个步骤,但质量仍然保持不变。
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \
-sColorConversionStrategy=/LeaveColorUnchanged \
-dAutoFilterColorImages=true \
-dAutoFilterGrayImages=true \
-dDownsampleMonoImages=true \
-dDownsampleGrayImages=true \
-dDownsampleColorImages=true \
-sOutputFile=document_flat.pdf document_original.pdfhttps://stackoverflow.com/questions/33691103
复制相似问题