Dompdf in custom files

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
pheligo
User
Posts: 1

Dompdf in custom files

Post 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));


arbei
User
Posts: 9292

Post 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.


Post Reply