wkhtmltopdf 图像不显示

发布于 2024-12-27 16:21:07 字数 110 浏览 3 评论 0原文

我正在使用 wkhtmltopdf 来制作 pdf,但除了不显示的图像之外,其他任何东西都可以工作。如何修复?

在 localhost:3000 中它可以工作,但在服务器上部署时它不起作用。

I am using wkhtmltopdf for make pdf but anything work except image that doesn't display.How fix?

IN localhost:3000 it work but when deploy on server it does't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我做我的改变 2025-01-03 16:21:07

这可能与 wkhtmltopdf 的 SSL 问题有关。您是否通过 HTTPS 访问生产服务器?如果是这样,请使用图像资源的绝对路径而不是相对路径。这意味着:

不会工作:

<img src="/image.jpg" alt="" />

可能会工作:

<img src="https://example.com/image.jpg" alt="" />

如果这解决了您的问题,如果您想避免此解决方法,以下线程可能会提供进一步的解决方案:
wkhtmltopdf 在 GitHub 上从 HTTPS 渲染图像时出现问题

This could be related to an issue wkhtmltopdf has with SSL. Do you access the production server via HTTPS? If so, use absolute paths rather than relative paths to your image resources. That means:

wont work:

<img src="/image.jpg" alt="" />

might work:

<img src="https://example.com/image.jpg" alt="" />

If this solves your issue, the following thread might provide further solutions if you want to avoid this workaround:
wkhtmltopdf issues rending images from HTTPS on GitHub

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文