DOM pdf codeigniter: Class 'DOMPDF' not found error

后端 未结 4 1741
孤独总比滥情好
孤独总比滥情好 2020-12-19 21:09

I trying to add DOM PDF library to my codeigniter application

1.Download dompdf and copy the dompdf folder to libraries folder.

2.Create file

4条回答
  •  心在旅途
    2020-12-19 21:31

    I have done pdf generation with tcpdf library but with a slightly different approach from you. Here is my solution with tcpdf. You can try it with Dompdf.

    Download tcpdf and put in third_party folder Make a file PDF.php in libraries folder with the following contents

     require_once APPPATH."third_party/tcpdf/tcpdf.php";
    
        class PDF extends TCPDF {
            public function __construct() {
                parent::__construct();
            }
        }
    

    In controllers folder create a file Createpdf.php with following codes

    defined("BASEPATH") OR exit("No direct script access allowed");
    
        class Createpdf extends CI_Controller {
    
            public function pdf()
            {
                $this->load->library("pdf");
                $data["content"] = "Hello from CodeIgniter with TCPDF...";
                $this->load->view("pdfreport", $data);
            }
        }
    

    and the pdfreport.php view is:

    $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $obj_pdf->AddPage();
    $obj_pdf->writeHTML($content, true, false, true, false, '');
    $obj_pdf->Output('output.pdf', 'I');
    

提交回复
热议问题