我希望能够使用PHP在现有的pdf文档上书写/覆盖文本。 我希望做的是拥有一个可以充当模板的pdf文档,并通过打开模板文档,覆盖相关文本并将结果用作新文档来填补空白。 模板文档是单个页面,因此不需要页面合并/操作。
有没有免费的图书馆可以做到这一点? 我应该去哪里看看? 我所做的大多数搜索似乎都是在合并文档/添加页面,而不是在现有页面上覆盖内容。
谢谢。
*编辑:这是我所做的:1.下载FPDF2.从以下位置下载FPDI + FPDF_TPL
[HTTP://呜呜呜.塞塔寺姑娘.的/products/PDF-PHP-solutions/分批地/downloads/]
以下是任何未来流浪者的示例代码(改编自www.setasign.de的示例):
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');
?>