您的位置:首页 > 编程语言 > PHP开发

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

2014-03-03 21:40 483 查看
1.需要给生成的pdf添加页眉和页脚
解决办法

 
    @page { margin: 180px
50px; }
    #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

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: