如何使用dompdf设置pdf的自定义宽度和高度? [英] How to set custom width and height of pdf using dompdf?

查看:337
本文介绍了如何使用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);

更多信息:https://github.com/dompdf/dompdf/wiki/用法

这篇关于如何使用dompdf设置pdf的自定义宽度和高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆