TCPDF 自定义页面大小 [英] TCPDF Custom page size
本文介绍了TCPDF 自定义页面大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个例子 展示了如何使用 A4、A5 等页面格式,但如何使用是否将 tcpdf 设置为使用 175 毫米 x 266 毫米等自定义尺寸?
This example on tcpdf's website shows how to use page formats like A4, A5 etc, but how do I set tcpdf to use custom sizes like 175mm x 266 mm?
感谢解决方案.
推荐答案
EDIT :我错了:你可以在参数中给出一个数组 (array($width, $height)) ..
我创建了一个 tcpdf 子类,并在其中修改了一些内容:getPageSizeFromFormat();这是代码:http://paste.pocoo.org/show/294958/.
I created a tcpdf subclass where I modified a few things : getPageSizeFromFormat(); Here is the code : http://paste.pocoo.org/show/294958/.
然后我调用我的自定义类,添加新格式并设置新格式:
Then I call my custom class, add a new format and set a new format :
$pdf = new CUSTOMPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
//Add a custom size
$width = 175;
$height = 266;
$orientation = ($height>$width) ? 'P' : 'L';
$pdf->addFormat("custom", $width, $height);
$pdf->reFormat("custom", $orientation);
这篇关于TCPDF 自定义页面大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文