I was working on a system that needed generate a PDF report of a view, I solved it as follows:
function report_view() {
...
$this->render();
require_once ('vendors/dompdf/dompdf_config.inc.php'); // import dompdf library
$dompdf = new DOMPDF();
$dompdf->load_html($this->output);
$dompdf->set_paper("a4", "landscape" );
$dompdf->render();
$dompdf->stream('ReportExample_'.date('d_M_Y').'.pdf');
exit(0);
}
You can see, that I used “$this->output” as parameter of load_html to get the output of the view.
I used the dompdf library.