2013-07-05 40 views
0

我試圖從html使用dompdf與codeigniter創建一個pdf。我有兩個HTML頁面。我的問題是,只有第一頁保存在PDF文件。第二個消失了。只有第一頁被保存爲html使用dompdf與codeigniter

這裏是我的代碼:

$this->load->library('pdf'); 
    $html = $this->load->view('reports_html/couver1','',true); 
    $html .= $this->load->view('reports_html/reportContentImageLeft','',true);              
    $this->pdf->load_html($html);               
    $this->pdf->render(); 

其他代碼

$this->data['view'] = $this->load->view('reports_html/reportContentImageLeft','',true); 
$html = $this->load->view('reports_html/couver1',$this->data,true); 
// $this->pdf->load_html($html); 
$this->pdf->load_view('reports_html/couver1',$this->data,true); 
$this->pdf->render(); 

我沒有像你說的,但僅在打印PDF文檔文件的第一頁

<!DOCTYPE HTML> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
     <title>on.plans - reports - cover page 1</title> 
     <link href="<?php echo base_url()."css/reports.css"?>" rel="stylesheet" type="text/css"> 
    </head> 
    <body> 
     <div id="page"> 
      <div id="section" class="cover"> 
       <div class="logo"> 
        <img src="/path/to/officeLogo.jpg" width="300px" height="150px"> 
       </div> 
       <h1>Meeting date</h1> 
       <h3>Project name</h3>      
      </div> 
     </div> 
    </body> 
</html> 
<?php echo $view; ?> 

我加入查看但它不起作用

感謝您的回答

+0

你在這行'$ html中使用[賦值運算符](http://www.php.net/manual/en/language.operators.assignment.php)後是否嘗試輸出$ html的值。= $​​ this-> load-> view()'它是否返回兩頁? – surfmuggle

回答

0

你可以嘗試這樣的事情:

$data['view'] = $this->load->view('reports_html/reportContentImageLeft','',true); 
$html = $this->load->view('reports_html/couver1',$data,true); 
$this->pdf->load_html($html); 
$this->pdf->render(); 
$dompdf->stream("test.pdf"); 

而在你reports_html/couver1視圖需要做這樣的事情<?=$view;?>

該解決方案是不是最好的 - 但它是工作。