我使用FPDI来编辑我现有的PDF文件,并且它的工作完美适用于单页。 正如你可以看到我正在编辑我的$tplIdx = $pdf->importPage(1);
首页。 我有六页PDF文件,需要在不同页面添加2个变量。编辑现有PDF多页使用FPDF和FPDI的文件
可以吗?怎么样?
<?php
require_once('fpdf.php');
require_once('fpdi.php');
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('ex.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 10, 10, 200);
// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(255,0,0);
$pdf->SetXY(50, 50);
$pdf->Write(0, "Ajay Patel");
$pdf->Output('newpdf1.pdf', 'D');
?>
在此先感谢!
@JA我已经导入6页的PDF文件,并输出单页,我希望所有的页面 –