wkhtmltopdf不渲染来自其他站点的图像。我发现许多开发人员建议在图像文件前加上前缀:
file://并添加完整路径。但是这种方法不适合我的需求。我需要渲染来自其他站点的图像,因为我有一个单独的图像提供程序service.Also,我已经尝试--图像标志。
我也试过用google.com。但我仍然得到没有任何图片的pdf格式。
xvfb-run wkhtmltopdf 'https://google.com' '/home/project/src/uploads/google.pdf'附注:我使用wkhtmltopdf 0.12.3.2。
发布于 2018-08-30 21:05:26
添加-a -s "-screen 0 640x480x16"作为xvfb-run的参数也确实解决了我的问题。
因此,正如上面所建议的,这确实会渲染图像:
xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf google.com test.pdf
发布于 2021-07-16 22:00:29
是的,这解决了我的问题,这是我的完整命令:
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');https://stackoverflow.com/questions/49418289
复制相似问题