如何为包含大量照片的长网页加速 wkhtmltopdf 和 pdfkit
我们使用 wkhtmltopdf 转换 html,生成数百个 pdf 页面,其中包含数百张大照片,在 ec2 小型实例上,每次转换大约需要 10 分钟。花费的时间肯定是由于大量照片,如果取出来,转换只需几秒钟即可完成。
我可以进行性能调整来加快 wkhtmltopdf 的速度吗?是cpu限制还是io限制?是否可以先放入占位符,然后用照片替换?
We are having wkhtmltopdf convert html that results in hundreds of pdf pages with hundreds of large photos, on a ec2 small instance this takes about 10 minutes per conversion. The time taken is definitely due to the large amount of photos, if taken out the conversion happens in a few seconds.
are there performance tweaks I can do to speed up wkhtmltopdf? is it cpu bound or io bound? would it be possible to have place holders put in and then be replaced by the photos afterward?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能花费太多时间为图像本身发出 http 请求。
如果你的 html 看起来像这样:
也许尝试像这样加载文件系统:
另外,如果可能的话,尝试在图像上指定宽度和高度,这应该会加快渲染速度。
但恐怕真正的问题可能是小型实例上的内存量和 IO 限制。尝试在本地系统上进行基准测试,它可能会快得多。
You might be spending too much time making http requests for the images themselves.
If your html looks like this:
Perhaps try filesystem loading like this:
Also, if possible, try to specify width and height's on your images, that should speed up rendering a bit.
But I'm afraid the real issue is probably the amount of memory and IO you are limited to on your small instance. Try and benchmark on a local system, it will probably be much much faster.