2016-09-22 40 views
2

在這裏,我使用dompdf生成PDF與一些標題,正文,頁腳。 但是,當我嘗試添加頁腳,它不附加。Dompdf頁腳未設置..?

它總是附帶身體代碼, 我想在底部設置頁腳。

任何人都可以弄清楚,我錯了下面的代碼?

代碼:

global $_dompdf_show_warnings; 
    global $_dompdf_debug; 
    global $_DOMPDF_DEBUG_TYPES; 
    global $_dompdf_warnings; 
    $_dompdf_show_warnings = FALSE; 

    require_once(realpath(APPPATH."third_party/dompdf")."/dompdf_config.inc.php"); 
    spl_autoload_register('DOMPDF_autoload'); 

    $dompdf = new DOMPDF(); 
    $dompdf->set_paper("letter", "portrait"); 

    $html = '<html> 
       <head> 
        <title> 
        </title> 
        </head> 

`enter code here`     <body style="margin:0; background-color:#ff9900; color:#ffffff;"> 
         <div> 
          <div style="margin:15px;"> 
           <div> 
            <span style="font-size:25px; font-weight:600;"> 
             Hi, John 
            </span> 
           </div> 
           <div> 
            <span> 
             Your account statement is here. 
            </span> 
           </div> 

           <div style="margin-top:15px; border: 2px solid;border-radius:5px; padding:10px; position:absolute; diplay:block;"> 
            <div style="float:left;">left</div> 
            <div style="float:right;">right</div> 
           </div> 
          </div> 
         </div> 
         <div style="background-color:#ffffff; color:#ff9900; position:fixed; bottom:0;width:100%;padding:10px;"> 
          <div> 
           <span> 
            <b><i>This is a system generated statement.</i></b> 
           </span> 
          </div> 
          <div> 
           <span> 
            <b><i> If you have any queries, email [email protected]</i></b> 
           </span> 
          </div> 
         </div> 
        </body> 
       </html>'; 


     $dompdf->load_html($html); 
     $dompdf->render(); 

     $dompdf->stream("dompdf_out.pdf", array("Attachment" => false)); 
+0

你的代碼示例中有一個隨機的「'在此輸入代碼」文本? – BrianS

回答

0

在DOMPDF(直至幷包括版本0.7.0)元素(一般來說)開始呈現與它們第一次出現的頁面。因此,您需要將任何頁眉/頁腳內容放在文檔的頂部。