本文介绍了mPDF 5.7.1 - 图像显示为破损[x]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mPDF(版本5.7.1)中遇到了一个小问题。

I have a small issue with mPDF (version 5.7.1).

这段代码应该生成带有图像文件的PDF:

This code should generate PDF with image file:

 $mpdf = new mPDF();
 $html = '<img src="https://www.google.pl/images/srpr/logo11w.png"/>';
 $mpdf->WriteHTML($html);
 $mpdf->debug = true;
 $output = $mpdf->Output();
 exit();

没有图像,只有 [x] 代替。

我已经使用了足够的搜索结果来说明它必须以这种方式完成,但我也尝试了实际的文件路径。还没有。

I've googled enough to get to the conclusion that it has to be done this way but I also tried realpath to the file. Still nothing.

我没有试过的唯一一件事是< img src =logo11w.png> 并将图像复制到文件夹中,因为我不知道应将文件复制到哪个文件夹中 logo11w.png

The only thing I haven't tried is <img src="logo11w.png"> and copying the image into the folder because I don't know into which folder I should copy file logo11w.png.

有什么建议?

推荐答案

在生成PDF时,我有与显示为[X]的PNG图像相同的问题与mPDF。

I had the same problem with PNG images being displayed as [X] when to generate PDFs with mPDF.

我补充说: $ mpdf-> showImageErrors = true;

之后: $ mpdf = new Mpdf();

消息:
$ b

and got the error message:

因此,在运行 apt-get install php5-gd 后生成带有PNG的PDF就像一个魅力一样!

So after running apt-get install php5-gd generating a PDF with a PNG worked like a charm!

这篇关于mPDF 5.7.1 - 图像显示为破损[x]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 06:25
查看更多