Hello everyone,I hope this message finds you well. I am writing to seek assistance regarding an issue I am facing while using the dompdf library in a Custom File with the “Includes common files” option enabled. I am attempting to generate a PDF file using dompdf, but I have encountered some difficulties.To provide you with a clearer picture, here is the code I have used in the Custom File:
<!DOCTYPE html>
<html>
<body>
<?php
// Include autoloader
require_once 'vendor/autoload.php';
// Reference the Dompdf namespace
use Dompdf\Dompdf;
// Instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->set_option('defaultFont', 'sans-serif');
// Load HTML content
$dompdf->loadHtml('Hello World');
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream();
?>
</body>
</html>
Despite executing this code, I am encountering an error message stating “Failed to load PDF document” when attempting to load the PDF file.I would greatly appreciate any assistance or guidance you can provide to help me resolve this issue. If there are any additional steps or considerations I should be aware of when using dompdf in Custom Files with the “Includes common files” option, please let me know.Thank you for your attention and support.