How to get page number on dompdf PDF when using “view”

前端 未结 5 1480
南笙
南笙 2020-11-30 11:49

Ok, so I use the following snippet to get \"views\" of HTML with PHP variables loaded in as $data so that I can do things like fill in tr\'s of dat

5条回答
  •  渐次进展
    2020-11-30 12:24

    Update Regarding changes with version of dompdf >= 0.7.0
    1. Because the dompdf_config.inc.php file has been removed from this release (and is no longer referenced) all dompdf options should be set at run time.
    4. The FontMetrics class is now instantiated instead of static. To simplify migration of embedded scripts from earlier versions of dompdf we provide access to the instantiated FontMetrics class via the $fontMetrics variable. Please update your embedded scripts. For example, FontMetrics::get_font('helvetica') would now be $fontMetrics->getFont('helvetica').
    ~ Thanks to Dennis Ameling's answer for the updated information.

    Found my answer by looking over the dompdf_config.inc.php file. As it turns out, DOMPDF_ENABLE_PHP is set to false thus causing the inline php script to be ignored. I simply edited dompdf_config.custom.inc.php to the following and all is fine and working with the later code in the view.

    In dompdf/dompdf_config.custom.inc.php

    At Run Time

    $dompdf->set_option("isPhpEnabled", true);
    

    Then, in my html file

    
        
        

    If you go this route, don't forget to restart Apache

提交回复
热议问题