2013-10-30 29 views
0

我已經下載從GitHub https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf錯誤DOM PDF使用笨

控制器功能

function pdf() 
    { 
    $this->load->helper('dompdf'); 
    // page info here, db calls, etc.  
    $this->data['query'] = $this->my_model->dashboard_db(); 
    $this->data['queryCmt'] = $this->my_model->dashboard_comment_task_db(); 
    $html = $this->load->view('home',$this->data, true); 
    $fn = 'file_pdf'; 
    $data = pdf_create($html, $fn, true); 
    write_file($fn, $data); 
    //if you want to write it to disk and/or send it as an attachment  
    } 

大教堂PDF助手功能

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
    function pdf_create($html, $filename, $stream=TRUE) 
    { 
    require_once("dompdf/dompdf_config.inc.php"); 

    $dompdf = new DOMPDF(); 
    $dompdf->load_html($html); 
    $dompdf->render(); 
    if ($stream) { 
    $dompdf->stream($filename.".pdf"); 
    } else { 
    return $dompdf->output(); 
    } 
    } 
    ?> 

這給了我一個服務器錯誤,但如果DOMPDF庫我在控制器中刪除一個pdf_create(),生成一個pdf文件。任何人都可以幫助一個本

+0

你得到的是什麼服務器錯誤? –

+0

有點像「可能因維護而關閉或配置不正確」。 – Serma

+0

查看服務器錯誤日誌 - 他們應該完全告訴你什麼是問題。 –

回答

0

在你home.php(視圖)文件,

刪除<thead><tbody>標籤和<html><head></head><body></body></html>

之間移除空間它將工作正常!