【发布时间】:2011-04-26 07:36:20
【问题描述】:
tcpdf 网站上的This example 展示了如何使用 A4、A5 等页面格式,但我如何将 tcpdf 设置为使用 175 毫米 x 266 毫米等自定义尺寸?
解决方案赞赏。
【问题讨论】:
标签: tcpdf
tcpdf 网站上的This example 展示了如何使用 A4、A5 等页面格式,但我如何将 tcpdf 设置为使用 175 毫米 x 266 毫米等自定义尺寸?
解决方案赞赏。
【问题讨论】:
标签: tcpdf
不需要编辑类... tcpdf 不接受宽度/长度参数,它只接受两个长度并确定哪个使用布局(纵向或横向)
$pageLayout = array($width, $height); // or array($height, $width)
$pdf = new TCPDF('p', 'pt', $pageLayout, true, 'UTF-8', false);
【讨论】:
转到 /config/tcpdf_config.php 并在第 117 行附近,修改该行:
define ('PDF_PAGE_FORMAT', 'A4');
通过
define ('PDF_PAGE_FORMAT', 'LETTER');
“LETTER”大写很重要,您可以在此文件中看到所有可能的值:tcpdf/include/tcpdf_static.php。
【讨论】:
在较新的 TCPDF 版本上,您可以通过多种方式定义页面大小:
setPageFormat() 方法http://www.tcpdf.org 的文档中的说明定义高级页面详细信息(MediaBox、Cropbox、BleedBox、TrimBox、ArtBox)。还要检查默认示例编号。 28 岁和 60 岁,http://www.tcpdf.org。
【讨论】:
说实话,现在你可以这样解决了。
//AddPage [P(PORTRAIT),L(LANDSCAPE)],FORMAT(A4-A5-ETC)
$pdf->AddPage('P','A5');
【讨论】:
// 8.5 X 13 英寸纸
$pdf = new Pdf('P', 'mm', array(215.9, 330.2), true, 'UTF-8', false);
【讨论】:
编辑 tcpdf.php 并添加新的页面类型或将现有类型修改为您的页面大小。
【讨论】:
上面的答案对我不起作用,所以我在这里添加我的解决方案 - 从http://www.tcpdf.org/examples/example_060.phps,更改 urx, ury 以达到您的目的
// set page format (read source code documentation for further information)
// MediaBox - width = urx - llx 210 (mm), height = ury - lly = 297 (mm) this is A4
$page_format = array(
'MediaBox' => array ('llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297),
//'CropBox' => array ('llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297),
//'BleedBox' => array ('llx' => 5, 'lly' => 5, 'urx' => 205, 'ury' => 292),
//'TrimBox' => array ('llx' => 10, 'lly' => 10, 'urx' => 200, 'ury' => 287),
//'ArtBox' => array ('llx' => 15, 'lly' => 15, 'urx' => 195, 'ury' => 282),
'Dur' => 3,
'trans' => array(
'D' => 1.5,
'S' => 'Split',
'Dm' => 'V',
'M' => 'O'
),
'Rotate' => 90,
'PZ' => 1,
);
// Check the example n. 29 for viewer preferences
// add first page ---
$pdf->AddPage('P', $page_format, false, false);
【讨论】: