Search code examples
phpcodeigniterdompdf

DOMPDF with CODEIGNITER


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


Solution

  • You need to use v0.6. v0.7 uses namespaces which are not supported in CodeIgniter.