php DOMPDF 中的自定义宽度和高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8835323/
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
Customized width and height in DOMPDF
提问by unknown
Is there anyway i can set the generated PDF's width and height? i want to customized the width and height of the PDF. Normally it would be on a size of a short bond paper but how can i customized it? lets say for example i want it to be 200 x 500 pixel in size?
无论如何我可以设置生成的PDF的宽度和高度?我想自定义 PDF 的宽度和高度。通常它会在一张短证券纸的尺寸上,但我如何定制它?比如说我希望它的大小为 200 x 500 像素?
Any idea would be very much appreciated! cheers!
任何想法将不胜感激!干杯!
回答by Michiel
You can set your own format, without having to change DOMPDF code, by passing an array when you're calling DOMPDF::set_paper(). Make sure it contains the width and the height in points, like this:
您可以通过在调用 DOMPDF::set_paper() 时传递一个数组来设置自己的格式,而无需更改 DOMPDF 代码。确保它包含以磅为单位的宽度和高度,如下所示:
$dompdf->set_paper(array(0, 0, 595, 841), 'portrait');
$dompdf->set_paper(array(0, 0, 595, 841), 'portrait');
回答by greut
DOMPDF handles the paper size via the configuration.
DOMPDF 通过配置处理纸张尺寸。
define ("DOMPDF_DEFAULT_PAPER_SIZE", "letter");
You can referrer to all available sizes there:
您可以参考那里的所有可用尺寸: