Welcome Guest, Not a member yet? Register   Sign In
rendering problem in Codeigniter 4
#1

I am trying to generate a PDF from a view, but encountering an error. I have already searched for a solution on Google, but couldn't find any helpful information. In my Controller, I have the following code:


require (APPPATH . "libraries/mPDF/vendor/autoload.php");

$mpdf = new \Mpdf\Mpdf();

$data_otpremnice['query'] = $this->Main_model->admin_pregled_otpremnice($otpremnice);

$data_list['list'] = $this->Main_model->otpremnica_list_item($otpremnice);

$last_racun['racun'] = $this->Main_model->br_racuna($otpremnice);

$mpdf->WriteHTML($this->load->view('otpremnice_pdf', array_merge($data_list, $data_otpremnice, $last_racun)));

$mpdf->Output('application/libraries/mPDF/Output/TEST.pdf','F');
However, I am receiving the following error message:


Message: WriteHTML() requires $html be an integer, float, string, boolean or an object with the __toString() magic method.
In my View page, I have HTML with PHP code like this:


<html>
blablaforeach ($query as $row) {echo $row->Mjesto_tvrtke;etc etc
}
blabla</html>
Can someone help me identify the problem?
Reply
#2

Because your using CodeIgniter 3 code.
PHP Code:
$mpdf->WriteHTML($this->load->view('otpremnice_pdf'array_merge($data_list$data_otpremnice$last_racun))); 
It should be something like this.
PHP Code:
$pdf view('otpremnice_pdf'array_merge($data_list$data_otpremnice$last_racun))
$mpdf->WriteHTML($pdf); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB