php 在 FPDF 中设置纸张尺寸

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10426853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:08:13  来源:igfitidea点击:

Setting paper size in FPDF

phpfpdf

提问by irwan

i want to seting paper size in fpdf to a half of letter size, it's approximately 8.5x5.5 inc. How can i do that?
My fpdf function in php language is

我想将 fpdf 中的纸张大小设置为 letter 大小的一半,大约为 8.5x5.5 inc。我怎样才能做到这一点?
我在 php 语言中的 fpdf 函数是

$pdf = new FPDF('P','mm','?????');

is there any solution? Thank's before for your help..

有什么解决办法吗?之前谢谢你的帮助..

回答by kuba

They say it right there in the documentation for the FPDF constructor:

他们在 FPDF 构造函数文档中就这么说:

FPDF([string orientation [, string unit [, mixed size]]])

This is the class constructor. It allows to set up the page size, the orientation and the unit of measure used in all methods (except for font sizes). Parameters ...

size

The size used for pages. It can be either one of the following values (case insensitive):

A3 A4 A5 Letter Legal

or an array containing the width and the height (expressed in the unit given by unit).

FPDF([字符串方向[, 字符串单元[, 混合大小]]])

这是类构造函数。它允许设置所有方法中使用的页面大小、方向和度量单位(字体大小除外)。参数 ...

尺寸

用于页面的大小。它可以是以下值之一(不区分大小写):

A3 A4 A5 Letter Legal

或包含宽度和高度的数组(以 unit 给出的单位表示)。

They even give an example with custom size:

他们甚至举了一个自定义尺寸的例子:

Example with a custom 100x150 mm page size:

自定义 100x150 毫米页面大小的示例:

$pdf = new FPDF('P','mm',array(100,150));

回答by irwan

/*$mpdf = new mPDF('',    // mode - default ''
 '',    // format - A4, for example, default ''
 0,     // font size - default 0
 '',    // default font family
 15,    // margin_left
 15,    // margin right
 16,     // margin top
 16,    // margin bottom
 9,     // margin header
 9,     // margin footer
 'L');  // L - landscape, P - portrait*/