我希望能够用PHP在现有的PDF文档上编写/覆盖文本。我希望做的是有一个pdf文档,它可以作为一个模板,并通过打开模板文档、覆盖相关文本以及将结果作为一个新文档来填补空白。模板文档是一个单独的页面,因此不需要合并/操作页面。
有没有免费的图书馆可以做到这一点?我该去哪里看看?我所做的大多数搜索似乎都是处理合并文档/添加页面,而不是在现有页面上覆盖内容。
谢谢。
*编辑:
以下是我所做的:
一。下载FPDF
2。从下载FPDI+FPDF_TPL
以下是未来流浪者的一些示例代码(改编自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');
?>