PDF generation using DOMpdf in CodeIgniter PDF generation using DOMpdf in CodeIgniter codeigniter codeigniter

PDF generation using DOMpdf in CodeIgniter


This problem is fixed in dompdf 0.6

or you may correct it by adding a condition in:

dompdf/include/style.cls.php

then search for if ( is_null($col) ) (may be: Line 1422 or near of it)

if ( is_null($col) )$col = self::$_defaults["color"];//see __set and __get, on all assignments clear cache, not needed on direct set through __set$this->_prop_cache["color"] = null;$this->_props["color"] = $col["hex"];}

add this condition also, and try.

if (is_array($col))     $this->_props["color"] = $col["hex"];


Step 1: Download Dompdf library from "https://github.com/dompdf/dompdf/releases".

Step 2: paste it in libraries folder like "\xamppp\htdocs\codeigiter\application\libraries".

Step 3: Also Create one file named like "Pdf.php" in libraries folder and paste below code in it.

require 'dompdf/autoload.inc.php';use Dompdf\Dompdf;class Pdf extends Dompdf    {public function __construct()    {    parent::__construct();          $dompdf = new Dompdf();     }}?>

Step 4: Create pdf controller and paste below code in this and run controller.

  <?php defined('BASEPATH') OR exit('No direct script access allowed');class Printbill extends CI_Controller {public function __construct(){parent::__construct();$this->load->library('pdf');}public function index(){    $this->load->library('pdf');    $this->pdf->loadHtml('html code or variable');    // $customPaper = array(0,0,570,570);    //$this->pdf->set_paper($customPaper);    $this->pdf->setPaper('A4','portrait');//landscape    $this->pdf->render();    $this->pdf->stream("abc.pdf", array('Attachment'=>0));    //'Attachment'=>0 for view and 'Attachment'=>1 for download file        }}           ?>