Dompdf remote image is not displaying in pdf

后端 未结 17 2147
臣服心动
臣服心动 2020-12-09 17:28

On my server pdf generated via dompdf was not displaying images. Because they are remote url images.(local images are working fine) then I come to know that it needs some se

相关标签:
17条回答
  • 2020-12-09 18:15

    I think you could add this

    private function change_url_image($data, $url) {    
        $str = $url; //for example "http://localhost/yoursite/";
        $str2 = str_replace($str, "", $data);
        return $str2;
    }
    

    to change url for image

    0 讨论(0)
  • 2020-12-09 18:17

    I had the same issue after doing a lot of R&D finally got the solutions.First you need to get the options of dompdf then set isRemoteEnabled with true.

        $options = $dompdf->getOptions(); 
        $options->set(array('isRemoteEnabled' => true));
        $dompdf->setOptions($options);
    
    0 讨论(0)
  • 2020-12-09 18:18

    There are two things to take care of.

    1. If using image from same server then use full directory path e.g. /var/www/html/project_folder/images/logo.jpg

    2. List item Use JPEG image instead of png or other types.

    0 讨论(0)
  • 2020-12-09 18:19

    I used this line of code

    <img src="{{ url('/frontened/images/jeevan-green-logo.png') }}" >
    

    It's working fine. Thanks.

    0 讨论(0)
  • 2020-12-09 18:23

    Try use full directory path with .jpg image

    I realized that jpg images appear when you host your files remotely.

    0 讨论(0)
提交回复
热议问题