42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
// 1. 手动加载入口文件
|
|
include __DIR__ ."/../include.php";
|
|
|
|
$pdf = new \Fpdi\Fpdi();
|
|
$pdf->AddGBFont();
|
|
$file = __DIR__ . '/test.pdf';
|
|
//获取页数
|
|
$pageCount = $pdf->setSourceFile($file);
|
|
//遍历所有页面
|
|
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
|
|
//导入页面
|
|
$templateId = $pdf->importPage($pageNo);
|
|
//获取导入页面的大小
|
|
$size = $pdf->getTemplateSize($templateId);
|
|
//创建页面(横向或纵向取决于导入的页面大小)
|
|
if ($size['width'] > $size['height']) {
|
|
$pdf->AddPage('L', array($size['width'], $size['height']));
|
|
} else {
|
|
$pdf->AddPage('P', array($size['width'], $size['height']));
|
|
}
|
|
if ($pageNo == $pageCount) {
|
|
$imgFile = __DIR__ . '/111.jpeg';
|
|
$pdf->Image($imgFile, 120, 60, 50, 50, 'jpeg');
|
|
}
|
|
$pdf->SetFont('GB', '', 10);
|
|
if ($pageNo == 1) {
|
|
$pdf->Text(22, 26, iconv("UTF-8", "gbk", '张三'));
|
|
$pdf->Text(55, 26, iconv("UTF-8", "gbk", '330108192238333333'));
|
|
}
|
|
$pdf->SetTextColor(211, 211, 211);
|
|
$txt = iconv("UTF-8", "gbk", '张三 330192238333333 张三 330192238333333 张三 330192238333333 张三 330192238333333 张三 330192238333333 张三 330192238333333');
|
|
for ($i=2; $i<6; $i++) {
|
|
$pdf->RotatedText(15, $i*50, $txt, 30);
|
|
}
|
|
//使用导入的页面
|
|
$pdf->useTemplate($templateId);
|
|
}
|
|
$pdf->Output('F', '2.pdf');
|
|
die();
|