Home  >  Q&A  >  body text

DomPDF: Image is unreadable or empty

<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粉743288436P粉743288436438 days ago494

reply all(2)I'll reply

  • P粉244155277

    P粉2441552772023-08-30 12:11:16

    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.

    reply
    0
  • P粉805107717

    P粉8051077172023-08-30 00:27:54

    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

    reply
    0
  • Cancelreply