📜  php 代码在现有 pdf 文件上添加文本 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:30.600000             🧑  作者: Mango

代码示例1
require_once('fpdf.php');require_once('fpdi.php'); function generatePDF($source, $output, $text, $image) { $pdf = new FPDI('Portrait','mm',array(215.9,279.4)); // Array sets the X, Y dimensions in mm$pdf->AddPage();$pagecount = $pdf->setSourceFile($source);$tppl = $pdf->importPage(1); $pdf->useTemplate($tppl, 0, 0, 0, 0); $pdf->Image($image,10,10,50,50); // X start, Y start, X width, Y width in mm $pdf->SetFont('Helvetica','',10); // Font Name, Font Style (eg. 'B' for Bold), Font Size$pdf->SetTextColor(0,0,0); // RGB $pdf->SetXY(51.5, 57); // X start, Y start in mm$pdf->Write(0, $text); $pdf->Output($output, "F");} generatePDF("template.pdf", "export.pdf", "Hello world", "image.jpg");