开发者

How to speed up wkhtmltopdf and pdfkit for long webpage with lots of photos

开发者 https://www.devze.com 2023-02-28 16:47 出处:网络
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 definit

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 c开发者_如何学运维an 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?


You might be spending too much time making http requests for the images themselves.

If your html looks like this:

<img src="http://someserver.com/images/000000001.jpg"/>

Perhaps try filesystem loading like this:

<img src="file:///users/images/00000001.jpg"/>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消