It seems like you’re providing additional information and a solution for the issue where DOMPDF images are not showing in a PHP script, particularly when trying to load remote URLs. If that’s the case, here’s an example of how you can enable remote URLs in DOMPDF:
// Include DOMPDF library
require ‘vendor/autoload.php’; // Adjust the path based on your project structureuse Dompdf\Dompdf;
use Dompdf\Options;// Initialize DOMPDF
$options = new Options();
$options->set(‘isHtml5ParserEnabled’, true);
$options->set(‘isPhpEnabled’, true);// Enable remote URLs
$options->set(‘isRemoteEnabled’, true);$dompdf = new Dompdf($options);
// Your HTML content with remote image URL
$html = ‘<html><body><img src=”https://example.com/your-image.jpg” alt=”Image”></body></html>’;// Load HTML content
$dompdf->loadHtml($html);// Set paper size (optional)
$dompdf->setPaper(‘A4’, ‘portrait’);// Render PDF (output to browser or save to file)
$dompdf->render();// Output the generated PDF
$dompdf->stream(‘output.pdf’, array(‘Attachment’ => 0));
In this example, the key part is setting the ‘isRemoteEnabled’ option to true, which allows DOMPDF to fetch and include images from remote URLs. Adjust the HTML content with your actual remote image URL.
Make sure you’ve updated to the latest version of DOMPDF from the GitHub repository to ensure that you have the most recent bug fixes and improvements.
Remember to adjust the path to the autoload file based on your project structure.