我使用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文件,並輸出單頁,我希望所有的頁面 –