【发布时间】:2016-08-07 21:32:51
【问题描述】:
为了使渲染的 PDF 文件正好是 11 英寸乘 8.5 英寸,我需要更改什么设置?现在,由于某种原因,我生成的 PDF 为 11.69 英寸 x 8.27 英寸。
上面的代码是生成 PDF 的唯一方法,我尝试使用“new FPDF”而不是“new FPDI”,但得到的只是错误。如何将此代码更改为 11x8.5?
<?php
ob_clean();
ini_set("session.auto_start", 0);
define('FPDF_FONTPATH','font/');
define('FPDI_FONTPATH','font/');
require('fpdf.php');
require('fpdi.php');
$pdf = new FPDI();
$pdf->setSourceFile("Flyer.pdf");
$tplIdx = $pdf->importPage(1);
$specs = $pdf->getTemplateSize($tplIdx);
$pdf->addPage($specs['h'] > $specs['w'] ? 'P' : 'L');
$pdf->useTemplate($tplIdx, 0, 0, 297, 210);
$pdf->SetFont('helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
ob_end_clean();
$pdf->Output('marketing.pdf', 'F');
?>
【问题讨论】:
标签: pdf pdf-generation fpdf