FPDF/FPDI可以使用横向格式的PDF作为模板吗?

Jim*_*ran 12 php fpdf fpdi

我正在尝试使用FPDI将现有PDF导入为模板.模板采用横向格式.如果我将模板导入新文档,模板页面将以纵向形式插入,内容旋转90度.如果我的新文档是纵向的,则会显示完整内容,但如果新文档也是横向文档,则会裁剪内容.

是否可以使用FPDI的横向模板?

cro*_*ono 26

当然,这没问题.只需在调用"addPage()"时添加"L"作为参数.这是一个适合我的样本(模板是横向的)

<?php
require_once('fpdf.php');
require_once('fpdi.php');

$pdf =& new FPDI();
$pdf->addPage('L');
$pagecount = $pdf->setSourceFile('template.pdf');
$tplIdx = $pdf->importPage(1); 
$pdf->useTemplate($tplIdx); 
$pdf->SetFont('Arial'); 
$pdf->SetTextColor(255,0,0); 
$pdf->SetXY(25, 25); 
$pdf->Write(0, "This is just a test"); 
$pdf->Output('newpdf.pdf', 'F');

?>
Run Code Online (Sandbox Code Playgroud)