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

发布于 2024-07-08 08:56:55 字数 162 浏览 7 评论 0原文

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

是否可以将景观模板与 FPDI 一起使用?

I am trying to import an existing PDF as a template with FPDI. The template is in landscape format. If I import the template into a new document the template page is inserted in portrait form with the content rotated 90 degrees. If my new document is in portrait the full content appears, but if the new document is also landscape, the content is cropped.

Is it possible to use a landscape template with FPDI?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南烟 2024-07-15 08:56:55

当然,没问题。 只需在调用“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');

?>

sure, it is no problem. Just add "L" as parameter when calling "addPage()". Here is a sample which works fine for me (the template is in landscape)

<?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');

?>
枕头说它不想醒 2024-07-15 08:56:55

终于再次审视这个问题......虽然克罗诺的答案是完全有效的。 看来这只适用于更新版本的 FPDI 工具。 从 v1.1 升级到 v1.3 解决了该问题。

Finally got to look at this problem again... Although crono's answer is perfectly valid. It seems this only works with more recent versions of the FPDI tools. Upgrading from v1.1 to v1.3 solves the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文