首页 文章

html2pdf调整页面大小

提问于
浏览
0

我有html2pdf很好地将pdf附加到电子邮件但是,我需要将页面宽度调整为606px我可以在html中执行此操作但html是606px而pdf本身是标准字母宽度在portait中 . 有没有办法将文档限制到我需要的宽度?感谢名单

标记

3 回答

  • 2

    以下是此问题的解决方案:

    $html2pdf = new HTML2PDF('P', array($width_in_mm,$height_in_mm), 'en', true, 'UTF-8', array(0, 0, 0, 0));
    

    宽度和高度应为MM . 如果您使用英寸将其转换为MM .

    式:

    $width_in_mm = $width_in_inches * 25.4; 
    $height_in_mm = $height_in_inches * 25.4;
    

    不要四舍五入 . 即使它有一个小数点,也使用精确的转换 .

    希望这个答案能解决你的问题 .

  • 0

    在构建HTML2PDF时,您可以更改PDF的输出以更适合您的目的 .

    http://www.prepressure.com/library/paper-sizes

    以下是一些兼容的页面大小 .

  • 0

    HTML2PDF CLass的构造函数

    public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8))
    {
    

    通过定义页面大小来调整 $format 变量

    $format =array('user_defined_height','user_defined_width'); //for user-defined sizes accepts only in millimeter
    

    在你的情况下606px = 160.3375mm

    $ format = array('160.3375','160.3375');

相关问题