I use MPDF to generate pdf files in the encoder.
my controller function looks like
function save_pdf($std_id) { $data['section1_report']= $this->common_model->get_details('tbl_section1',array('id'=>$std_id)); $html = $this->load->view('reports/section1',$data,true); // print_r($html);exit; $this->load->library('pdf'); $pdf = $this->pdf->load(); $pdf->WriteHTML($html); $pdf->Output(); }
My pdf library
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class pdf { function pdf() { $CI = & get_instance(); log_message('Debug', 'mPDF class is loaded.'); } function load($param=NULL) { include_once APPPATH.'/mpdf/mpdf.php'; if ($params == NULL) { $param = '"en-GB-x","A4","","",10,10,10,10,6,3'; } return new mPDF($param); } }
I want to create a PDF file from a file of the form section1 . but when I call the controller function save_pdf , I got errors below

when i print_r($html);exit; , it displays all the contents of the view file. I used preg_replace_callback instead of preg_replace in mpdf/includes/functions.php , but it still shows an error like this

I studied mpdf documentation and worked correctly in simple php. but I want to create a pdf file in Codeigniter . How to solve such errors in mpdf ? I would appreciate any help where I can generate a pdf file using mpdf in Codeigniter . thanks.
source share