1

i have following code in the controller file which check for post varible pdf and execute following code

if(isset($_POST['pdf']) && $_POST['pdf']=="pdf")
            {
                $this->load->model('voutput_model');
                $final_view = $data['frmReport'];
                $PDF_Name = "report.pdf";
                $this->votput_model->pdf($PDF_Name,$final_view);

            }

I have following code in model file

class Voutput_model extends CI_Model{

    public function __construct()
    {
        parent::__construct();
        $this->CI = get_instance();
    }

    public function pdf($file_name,$filecontents){
        $this->pdf_path = $this->config->item('pdf_path');
        $this->load->library('htmltopdf/Html2fpdf');
        $file['Attach_path'] = $this->pdf_path.$file_name;
        $this->html2fpdf->generate_pdf($file['Attach_path'],$filecontents,'Y');
    }
}

while i am executing the code i am getting error as below:

Severity: Notice
Message: Undefined property: Voutput::$Voutput_model
Filename: controllers/voutput.php
Fatal error: Call to a member function pdf() on a non-object in 
            C:\xampp\htdocs\asset\application\controllers\voutput.php 
safarov
  • 7,573
  • 1
  • 34
  • 51
user493619
  • 145
  • 1
  • 4
  • 14

1 Answers1

4

You need to load model before use . Try this

 $this->load->model('votput_model');
 $this->votput_model->pdf($PDF_Name,$final_view);
safarov
  • 7,573
  • 1
  • 34
  • 51