HTML到PDF缩放问题

时间:2018-10-16 19:13:07

标签: php pdf dompdf

我正在使用dompdf从HTML文件生成PDF。该文件正常显示在我的屏幕上。但是,当我尝试从html文件生成pdf时,该pdf显示的内容像通常在屏幕上显示的一样减少了一半。阅读dompdf文档后,他们说这只是css的问题,但是我已经调整了许多属性,但无济于事。这是我的代码

 $dompdf = new Dompdf();
    $dompdf->set_option('isRemoteEnabled', TRUE);

    ob_start();

    echo $cbx->GeraHTMLBoleto($i); //Outputs the html

    $content = ob_get_contents();

    ob_end_clean();

    libxml_use_internal_errors(true);

    $doc = new DOMDocument();
    $doc->loadHTML($content);

    $head = $doc->getElementsByTagName('head')->item(0);
    $css_rule = $doc->createElement('style', 'table {-webkit-transform: scale(0.05);}');
    $head->appendChild($css_rule);

    $content = $doc->saveHTML();

    //var_dump($head);die;
    $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'ISO-8859-1');

    $dompdf->loadHtml($content, 'ISO-8859-1');
    $dompdf->setPaper('a4', 'portrait');
    //$customPaper = array(0,0,800,700);
    //$dompdf->setPaper($customPaper);
    $dompdf->render();
    $dompdf->stream();

0 个答案:

没有答案