DomPDF: Image not readable or empty
Following helped me like charm, at least localy, and even with
define("DOMPDF_ENABLE_REMOTE", false);
The solution is to change the image SRC to the absolute path on the server, like this:
<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 to this: lost in code
Laravel DOMPDF: how to load image from storage folder?
In the end, I bypassed the route and used a str_replace
to switch /media/
to the absolute path like so:
str_replace('/media/', '../storage/app/', $link);
Slightly counter-intuitive to go from public
to storage
in the HTML but it seems to be the only way for DOMPDF to render the image. Also found out that DOMPDF won't render remote images over HTTPS.
Dompdf remote image is not displaying in pdf
I had the same problem,
dompdf image not found on live server
I found its solution, you just need to double check the image path,
Considering your live server image path
<img src="http://www.example.com/public/images/thumb.png">
You just need to change it to,
<img src="public/images/thumb.png">
Note: Make sure that, all settings are same as you have already made.
I hope this will help you.
Images are not displaying using DOMPDF library
Since URLs can point anywhere and that is not how pdfs are supposed to work, you have to embed your whole image by encoding it as base64
like this example here https://stackoverflow.com/a/8499716/5956589
<div>
<p>Taken from wikpedia</p>
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>
Note that the format is data:[<mediatype>][;base64],<data>
Refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs to fully understand how this works
dompdf : image not found or type unknown
You should be using the full URL instead of a direct path. Especially when it is not a static image: dompdf will open that php script directly, so it won't be executed as if it's a PHP script.
If the full URL doesn't work, you can also show what the result of header.php is. Some good things to keep in mind are to send proper content-type headers and so on.
Related Topics
How to Get Multiple Value from Post Variable Using Same Name
Laravel App Storage Images Failed to Load and Redirect to 404
Unset Post Variables After Form Submission
Can You Assign Multiple Variables At Once in PHP Like You Can With Java
How to Get Filename from a Variable (Url) in PHP
Display Data from Database to Dropdown Codeigniter
Convert Accented Characters to Their Plain Ascii Equivalents
Php: How to Detect If a Session Has Expired Automatically
How to Use a Findby Method With Comparative Criteria
Session Data Not Preserved After Redirection
How to Get the Values of Input Using PHP
How to Install and Use PHP on Macos Via Brew
Get Total Number of Members in Discord Using PHP
Laravel Ajax Response Return HTML Elements
Remove Comma on Last Item of Foreach
What Is the Regular Expression to Validate a Comma Delimited List But Ending With '&' and a Word