我希望能够使用PHP在现有的pdf文档上书写/覆盖文本。我希望能做的是有一个可以作为模板的PDF文档,并通过打开模板文档,覆盖相关文本并将结果作为新文档提供给他们来填补空白。模板文档是单页,因此页面合并/操作不是必需的。在PHP中使用PDF模板文档进行书写/绘图
有没有免费的图书馆可以做到这一点?我应该看的任何地方?我所做的大多数搜索似乎都处理合并文档/添加页面,而不是将内容覆盖在现有页面上。
感谢。
*编辑: 这里是我做过什么: 1.下载FPDF 2.下载FPDI + FPDF_TPL从
http://www.setasign.de/products/pdf-php-solutions/fpdi/downloads/
这里是任何未来的娃儿一些示例代码(改编自样本在www.setasign.de):
<?php
include('fpdf.php');
include('fpdi.php');
// initiate FPDI
$pdf =& new FPDI();
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('templatedoc.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page as the template
$pdf->useTemplate($tplIdx, 0, 0);
// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(255,0,0);
$pdf->SetXY(25, 25);
$pdf->Write(0, "This is just a simple text");
$pdf->Output('newpdf.pdf', 'D');
?>
很高兴你在答案的例子中编辑过,为此+1,容易不是吗? :-) – Orbling 2010-11-29 02:13:00
是的!而且在几周内我会忘记我已经完成的工作并再次寻找它,这也会对我有所帮助:P(对于我的项目还没有实现它,只是发现了如何)。 – 2010-12-02 03:14:09
你有没有找到任何方法来追加图像在现有的文件,而不是写文字? – 2014-10-15 06:52:13