mPDF不显示生成的PDF中的图像,而是显示红色x符号和背景图像的完整URL

最近,我已经从登台服务器转移到生产服务器,我无法访问这些服务器中的任何一个。 这两个服务器都是linux。 在新的服务器上,使用mPDF和symfony 1.4框架生成pdf时,不会显示卢比符号之类的图像,而是在pdf中显示一个红色的小“x”符号。 此外,当我尝试将背景图像转换为pdf时,完整的图像路径(如“http://example.com/image/rupee-image.jpg”)将显示,而不是图像。 卢比符号,其他图像和背景图像在我的暂存服务器上工作得很好。 当我执行$mpdf->showImageError()时,它会说“mpdf图像错误:找不到图像文件”,并且将url粘贴到浏览器中会完美地显示图像。 任何帮助都将非常感谢。

mPDF is telling you that it's not finding the image.

Without seeing your code it's difficult to hint you on what's wrong.

Still you probably what to try referring to your images using a full path locally.

So instead of reference like http://example.com/image/rupee-image.jpg

use something like /var/www/mysite/image/rupee-image.jpg , same as if checking the image is there using the command line.

HTH

I fixed it myself... I have created a variable in my template and then replaced that variable with image location from my action class, using $mpdf->WriteHTML(str_replace('rupee_symbol','₹',$html1));

I had similar problem, i fixed it with replacing http:// to https://. Watch out for it.

My problem was PHP 7 in this case! I check condition

if (!empty('/images/someimg.png')) {
    echo '<img ...';
} else {
    echo 'error in PHP 7';
}

Be carefull using it. Version PHP 7.0.19

I converted the image to base64 format and it worked.