Page 1 of 1

How to use pdf in custom files? (v2022)

Posted: Mon Jan 23, 2023 9:06 pm
by feligo

The following code is not working:

$html = "<h1> WELCOME TO PHP Dompdf </h1>";

use Dompdf\Dompdf;

ob_get_clean(); // Clear Buffer - this is very important!!!

$document = new Dompdf();
$document->loadHtml($html);
//$document->setPaper('A4', 'portrait');
$document->setPaper("A4", "$orientation");
$document->render();
$document->stream("Payslips", array("Attachment"=>0));


Re: How to use pdf in custom files? (v2022)

Posted: Tue Jan 24, 2023 9:04 am
by arbei

In general, Custom Files ares used to add your own pages to your site, not to output files. If you just want to output files, you better use route actions, see viewtopic.php?t=49447.