2011-02-17 80 views
2

我使用dompdf創建了一個PDF文件,該文件被創建爲即時創建的PDF文件,其唯一目的是作爲PDF生成器的輸入,但是我遇到了麻煩這一點,我實現了代碼this thread,一切工作正常(我可以輸出一個簡單的PDF),但是當我嘗試給它一個更具體的網址我得到這個錯誤:使用CodeIgniter生成PDF

An Error Was Encountered Unable to load the requested file

下面是有問題的代碼:

function printPDF(){ 

      //write_file() usa un helper (file) 
      $this->load->library('table'); 
      $this->load->plugin('to_pdf'); 
      // page info here, db calls, etc. 
      $query = $this->db->get('producto'); 
      $data['table'] = $this->table->generate($query); 
      $path_url = base_url().'print/existencias.html'; 
      write_file($path_url, $data['table']); 
      $html = $this->load->view($path_url, 'consulta', true); 
      pdf_create($html, 'consulta'); 
     } 
+0

在這裏你可以找到很好的庫 http://stackoverflow.com/questions/9707967/convert-htmlcss-to-pdf-using-codeigniter – Buddhi 2012-10-03 12:23:40

回答

0

不確定確切的問題,但請檢查以下內容:

1)如CI手冊中所述,load-> view的第二個參數應該是關聯數組或objet,通過提取轉換爲變量。這可能會產生一些問題,生成$ html。

2)嘗試使$ path_url相對於application/views目錄,如CI手冊中所述。

0

你應該使用tcpdf來創建pdf。 //例如創建控制器:

public function create_pdf() 
    { 
    $this->load->library("Pdf"); 
    $data['results'] = // your data 
    $this->load->view('pdfview',$data); 

    } 


//pdfview is the page having tcpdf code and your pdf code.