在Codeigniter中生成html页面,使用Wkhtmltopdf进行打印

I want to create a temporary html page or view dynamically to use Wkhtmltopdf and export it as a PDF document from that file. It is a Codeigniter project (with which I'm not that familiar..) so firstly I am wondering if it is possible?

My approach is simply:

$pdf = new Pdf();
$pdf->addPage('http://pageToAdd.php');
$pdf->saveAs('/path/to/saveFolder/' . $filename);

Which is generating a pdf from the addPage, but I want that page to be created with dynamic contentent fetched from the database so I was thinking that I should load a view, save it temporary and then assign that file as pageToAdd.php. Is this is possible and if so, how and where should I start?

You can render a template into a variable:

$string = $this->load->view('myfile', ['foo' => 'bar'], true);

And also you can save it temporary if you need for creating pdf.