如何使用dompdf设置pdf的自定义宽度和高度?
问题描述:
当我使用dompdf创建pdf时,它将生成为默认的宽度和高度。我想设置我创建的pdf的自定义宽度和高度。如果在dompdf中是不可能的,那么请为php建议其他插件。
When I create my pdf using dompdf it generates it as default width and height. I want to set custom width and height of my created pdf. If it is not possible in dompdf then kindly suggest some other plugin for php.
答
默认情况下,它将在美国字母上呈现,您可以使用以下方法进行更改:
By default it's going to render on 'US Letter', you can change this by using:
$dompdf->set_paper(DEFAULT_PDF_PAPER_SIZE, 'portrait');
您可以使用'letter','legal','A4'等。
You can use 'letter', 'legal', 'A4', etc..
不过,您可以这样设置自己的大小:
Nevertheless you can set your own size like this:
$customPaper = array(0,0,360,360);
$dompdf->set_paper($customPaper);