php使用DomPDF时遇到的问题及解决…

来源:互联网 发布:虚拟mac识别iphone 编辑:程序博客网 时间:2024/06/05 22:50
1.需要给生成的pdf添加页眉和页脚
解决办法
 
    @page { margin: 180px50px; }
    #header { position:fixed; left: 0px; top: -180px; right: 0px; height: 150px;background-color: orange; text-align: center; }
    #footer { position:fixed; left: 0px; bottom: -180px; right: 0px; height: 150px;background-color: lightblue; }
    #footer .page:after {content: counter(page, upper-roman); }
 
 
   

Widgets Express

 
 
//页脚需要显示总页数及当前页数
if (isset($pdf) ){
   $font = Font_Metrics::get_font("yourfont","normal");
   $size = 9;
   $y = $pdf->get_height() -24;
   $x = $pdf->get_width() -15 -Font_Metrics::get_text_width("1/1",$font,$size);
   $pdf->page_text($x, $y, "{PAGE_NUM}/{PAGE_COUNT}",$font,$size);}
 
 
   

the first page

   

the second page

 

0 0