DomPDF: Image is unreadable or empty
P粉743288436
P粉743288436 2023-08-29 14:06:26
0
2
520
<p>For some reason, DomPDF does not render images contained in the html it is parsing: </p> <p>However, when the image is returned as html, the image is rendered on the page: </p> <p>I've looked at these questions and made sure DOMPDF_ENABLE_REMOTE is set to true and verified file permissions: </p><p> dompdf image is not a real image, cannot be read or is empty</p><p> Image error in ZF2's DOMPDF</p> <p>Is there anything else I should check? </p>
P粉743288436
P粉743288436

reply all(2)
P粉244155277

Since another answer suggested enabling the remote option in module.config.php and I haven't been able to add a comment yet, I thought it would be best to answer that the file does not exist in newer versions of DomPDF.

If you need to include a remotely stored image in a newer version, you must pass it as an option to the constructor:

$dompdf = new Dompdf(array('enable_remote' => true));

This solved the problem I was having.

P粉805107717

The following helped me fall in love with glamour, at least locally, even with

define("DOMPDF_ENABLE_REMOTE", false);

The solution is to change the SRC of the image to the absolute path on the server, as follows:

<img src="/var/www/domain/images/myimage.jpg" />

All of the following worked for me:

<img src="<?php echo $_SERVER["DOCUMENT_ROOT"].'/placeholder.jpg';?>"/>
<img src="<?php echo $_SERVER["DOCUMENT_ROOT"].'\placeholder.jpg';?>"/>
<img src="<?php echo $_SERVER["DOCUMENT_ROOT"].'./placeholder.jpg';?>"/>

$_SERVER["DOCUMENT_ROOT"] is C:/wamp/www/ZendSkeletonApplication/public

Thanks for this: Lost in Code

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template