DOMPDF doesn't work with external css file

后端 未结 2 871
说谎
说谎 2020-12-07 01:03

I\'m using Zend Framework and DOMPDF library. When I test it with inline css everything works perfectly. But when I tried to move css code to the external file rules are not

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 01:26

    This has in fact nothing to do with Zend Framework, but you need to supply DomPDF the right path to load the "external" files from.

    $dompdf = new DOMPDF();
    $dompdf->setBasePath(realpath(APPLICATION_PATH . '/path/to/css/'));
    $dompdf->loadHtml($html);
    $dompdf->render();
    

    See also the manual of DomPDF for this feature.

提交回复
热议问题