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 controller a piece of code like this
public function generatepdf(){
$this->load->helper('file');
require_once(APPPATH.'third_party/dompdf/autoload.inc.php');
$domdpf = new DOMPDF();
$domdpf -> loadHtml('<h1>HELLO WORLD</h1>');
$domdpf -> setPaper('A4','Landscape');
$domdpf ->render();
$domdpf->stream();
}
But I am getting a error saying
Fatal error: Class 'DOMPDF' not found in C:\Apache24\htdocs\faceloan\faceloan\application\controllers\moneyexchange.php on line 2495
Since v. 0.7 you need to include in your code reference to dompdfs namespace:
You can integrate the DomPDF with Codeigniter in two easy steps.
1) Download the domPDF library and place it into application/library directory.
2) Create a file name pdf.php file, place following code inside the file and place it into library directory.
Now in your Controller file call it as this
You can get full step by step configurations here
@Zedd Answer is right
but for the latest version as on this post date, the following will work.
application/libraries/Pdf.php
At your controller
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
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.
Try this library https://github.com/hanzzame/ci3-pdf-generator-library
This library using
You need to use v0.6. v0.7 uses namespaces which are not supported in CodeIgniter.