wkhtmltopdf不会渲染其他网站的图片。我发现许多开发人员建议只为图像文件添加前缀:
file://
并添加完整路径。但这种方法不符合我的需要。我需要从其他网站渲染图像,因为我有一个单独的图像提供者服务。另外,我已经尝试过--images flag。
我也试过google.com。但我仍然得到没有任何图像的PDF格式。
xvfb-run wkhtmltopdf 'https://google.com' '/home/project/src/uploads/google.pdf'
P.S。我使用wkhtmltopdf 0.12.3.2。
答案 0 :(得分:2)
将-a -s "-screen 0 640x480x16"
添加为xvfb-run
的参数确实确实为我解决了。
因此,如上所述,它确实可以渲染图像:
xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf google.com test.pdf
答案 1 :(得分:0)
是的,这解决了我的问题,这是我的完整命令:
exec('xvfb-run -a -s "-screen 0 640x480x16" -- /usr/bin/wkhtmltopdf --quiet --enable-local-file-access --page-size Letter /tmp/html.html /tmp/pdf.pdf');