简体   繁体   中英

Image not rendering in dompdf

I am using codeIgniter and dompdf for my application for generating pdfs. The below code is the code which i am using to display an image.

<div class=\"block_head\">
     <h2>Image display</h2>";
     $image_location = "/images/xxx.png";
     $html .="<img src=\"".$image_location."\" width=\"200\" height=\"200\" />
</div>";

I tested and debugged all ways whether i am doing something wrong. Like this first i checked whether the path is wrong. This is path on the server. It's correct. I tested by echoing $html also it's showing perfectly path. When i clicked on that path image is displaying. But when i am trying to render it in pdf it's not displaying.

Note: PDF is generating perfectly without image.

Try as below

if you are providing full URI to the image it is treated as external, so defined costant DOMPDF_ENABLE_REMOTE must be set to true.

Are you loading this document into dompdf using $dompdf->load_html($html); ? If so then you're probably running into a context problem. When you load a document in this manner dompdf has no knowledge of the document base path. Because of this it assumes you are working from the local file system. In this context the root path "/" translates to the root of the local file system not the root of the web content directory. Either use a path relative to the PHP file implementing dompdf, or specify the full path in the current files system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM