trying to create a simple pdf, but keeps returning an error when viewing “Failed to load PDF document.” code copied from phpM export function. options and other items not used.
some function() {
$Options = [];
$PdfBackend = "";
$FileExtension = "pdf";
$PageSize = "a4";
$PageOrientation = "portrait";
$options = new \Dompdf\Options($Options);
$options->set("pdfBackend", $PdfBackend);
$options->set("isRemoteEnabled", true); // Support remote images such as S3
$options->setDefaultFont('Courier');
$chroot = $options->getChroot();
$chroot[] = UploadTempPathRoot();
$chroot[] = UploadTempPath();
$chroot[] = dirname(CssFile(Config("PDF_STYLESHEET_FILENAME"), false));
$options->setChroot($chroot);
$campaignid = 5;
$employeeid = 5;
$fileName = "test.pdf";
$file = "html/test.html";
$html = file_get_contents($file);
$dompdf = new \Dompdf\Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper($PageSize, $PageOrientation);
$dompdf->render();
$dompdf->stream('5.pdf', array("Attachment" => true));
}
<html lang="en">
<body>
hello world
</body>
</html>