Page 1 of 1

Dompdf in custom files

Posted: Wed Jan 25, 2023 5:58 pm
by pheligo

The following code works in phpmaker 2020 but does work in phpmaker 2022. How can I make it work in phpmaker 2022?

$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->render();
$document->stream("Payslips", array("Attachment"=>0));


Re: Dompdf in custom files

Posted: Thu Jan 26, 2023 10:56 am
by arbei

Custom Files are for adding your own pages with content. If you want to add a route to output your PDF, read viewtopic.php?t=49447.

If you must use Custom File, you should put your code in Page_Load or Page_Render server event.

You should also use fully qualified name for dompdf, see Using namespaces: Basics.