I am trying to get dompdf working with codeigniter, I download the file from here https://github.com/dompdf/dompdf/releases the version was 0.7.0 and then I put inside my co
@Zedd Answer is right
but for the latest version as on this post date, the following will work.
application/libraries/Pdf.php
ci()->load->view($view, $data, TRUE);
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
$time = time();
// Output the generated PDF to Browser
$dompdf->stream("welcome-". $time);
}
}
At your controller
function pdf_gen(){
$this->load->library('pdf');
$this->pdf->load_view('main_report');
}
Obviously main_report is the view file at application/views/main_report and you can send data for the view file like the following too
$this->pdf->load_view('main_report', $data);
And Note
I placed the dompdf folder in the application/thirdparty folder and not in the application/libraries.
Make sure you have commented out all print, echo functions in your controller method, else you might get an error saying something similar to "the pdf file is damaged".
Hope this post was usefull.