How can I pass data to dompdf from controller? How can I pass data to dompdf from controller? codeigniter codeigniter

How can I pass data to dompdf from controller?


The view() method accepts three parameters. You can pass your data as the second parameter. By setting the third parameter to true, you are able to load the view as a string to pass to your pdf class.

    function dompdf(){       $data['name'] = "name";       $html = $this->load->view('contracts/equipment_pdf', $data, true);       $this->load->library('dompdf_gen');       $this->dompdf->load_html($html);       $this->dompdf->render();       $this->dompdf->stream("test.pdf", array("Attachment" => 0));   }

For the above example, you can access the data in your view using:

<?php echo $name; ?>