render result to variable

I need to create pdf file.

For this purpose I am using tcpdf.

I have already View displayed as html page. Instead I want to render result not to the screen, but to the variable.

Something like

$var = renderPartial(‘NameOfView’);

And then use variable $var to put it into pdf.

Something like

$pdf->writeHTML($var, true, false, false, false, ‘’);

3rd argument ;)

Check the documentation for renderPartial() -

If you want to render a view with a variable you can use

$var = renderPartial("$NameOfView");

With “” instead ‘’