Are you having problems with images not displaying in DomPDF generated PDFs?
The probable reason is because you’re linking your images in HTML with a path from the script or with an absolute URL like this:
<img src="images/myimage.jpg" />
OR
<img src="https://domain.com/images/myimage.jpg" />
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" />
That will fix the problem!
Hi Antonie
How are you? 🙂
I have this same problem on a project I’m currently working on. (You know the link by now). It seems to a be (according to the sporadic documentation that exists) a permission issue problem.
Even if you change the dompdf_config.custom.inc.php file settings, you still have to look into having proper permissions for the script.
You need to make sure external urls are turned on, as dompdf considers absolute urls as external (go figure)…:
define(“DOMPDF_ENABLE_REMOTE”, true);
You still need to make sure the temporary folder exists and is writable, but with a minor hack, you can make sure it works on your site, just create a subfolder in the dompdf folder:
define(“DOMPDF_TEMP_DIR”, DOMPDF_DIR.”/tmp”);
To help me with those pesky absolute urls, I found a small piece of code (I’d give a link if I remembered where) that returns relative urls instead, you just need to enter the relevant steps backward in proper relation.
function make_href_root_relative($input) {
return preg_replace(‘!http(s)?://’ . $_SERVER[‘SERVER_NAME’] . ‘/!’, ‘/’, $input);
}
Salvou minha vida… Obrigado
It is my pleasure, I’m glad the post helped you.
Hi,
How can i put 2 same Images on PDF ?
I used dompdf.
please help.
Thank you, it solved my problem.
Thanks! finally a solution that did the trick!
Hi , it doesn’t solve my problem in remote server , in local it works but in remote it doesn’t…