wkhtmltopdf 导出带图像的 pdf 不起作用,图像看起来像找不到

wkhtmltopdf export pdf with image doesnt work, image look linke not found

Image dump

当我尝试导出带有图像的 pdf 并使用转储(dd)时,我可以看到我的图像,但是当导出它们时我遇到了这个问题image doesnt render

我需要做什么?可能是我在服务器上没有所需的模块?或者我需要更改我的 html?

@if(isset($photo) && count($photo) > 0)
    <div style="margin-top: 30px;">
        @foreach($photo as $image)
        <img height="200" width="200" src="{{$image}}">x
        @endforeach
    </div>
@endif

找不到图片。我不太熟悉 Laravel,但其中一个应该可以工作:

  • 相对路径/img/file.jpg
  • 您在浏览器中输入的路径https://example.com/img/file.jpg
  • 在 Windows
  • 上的命令行 /var/www/img/file.jpgC:\www\img\file.jpg 中输入的路径

我忘了它需要哪一个,但是尝试所有三个,我相信其中一个会起作用。

只需安装最新版本的 wkhtmltopdf

sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb

sudo apt install ./wkhtmltox_0.12.6-1.bionic_amd64.deb

它在 Ubuntu 18.04

对我有用