load->library('pdf'); foreach ($tpl as $value) { $ci->load->view($value, $data); $html = $ci->output->get_output(); $ci->dompdf->loadHtml($html); // setup size $ci->dompdf->setPaper('A4', 'portrait'); // Render the HTML as PDF } // _die($html); // Get output html // add external css library // $html .= ''; // Load pdf library $ci->dompdf->render(); // echo $output = $ci->dompdf->output(); // Output PDF (1 = download and 0 = preview) $ci->dompdf->stream($name, array("Attachment" => 0)); } function generate_html($name, $tpl, $data) { $ci = &get_instance(); $data['data'] = $data; $html = ''; $ci->load->library('pdf'); foreach ($tpl as $value) { $html = $ci->load->view($value, $data, true); // Render the HTML as PDF } return $html; } ?>