jamboljack

mPDF Download

May 3rd, 2015
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. public function downloadpdf()  
  2. {
  3.     $pak_id = $this->uri->segment(3);
  4.     $data['detail'] = $this->pak_model->select_by_pak($pak_id)->row(); 
  5.        
  6.     $time = time();
  7.     $filename = 'CetakPAK_'.$pak_id.'_'.$time;
  8.     $pdfFilePath = FCPATH."/download/$filename.pdf";       
  9.        
  10.     if (file_exists($pdfFilePath) == FALSE){
  11.         ini_set('memory_limit','50M');
  12.         $html = $this->load->view('printpdf_view', $data, true);
  13.              
  14.         $this->load->library('pdf');
  15.         $pdf = $this->pdf->load();
  16.         $pdf->SetHeader('');
  17.         $pdf->SetFooter('');
  18.         $pdf->WriteHTML($html);
  19.         $pdf->Output($pdfFilePath, 'F');
  20.     }
  21.     redirect("/download/$filename.pdf");
  22. }
Add Comment
Please, Sign In to add comment