FPDF/FPDI可以使用横向格式的PDF作为模板吗? [英] Can FPDF/FPDI use a PDF in landscape format as a template?

查看:254
本文介绍了FPDF/FPDI可以使用横向格式的PDF作为模板吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

是否可以将横向模板与FPDI一起使用?

Is it possible to use a landscape template with FPDI?

推荐答案

确定,这没问题.只需在调用"addPage()"时将"L"作为参数添加即可.这是一个适合我的示例(模板位于横向)

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

?>

这篇关于FPDF/FPDI可以使用横向格式的PDF作为模板吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆