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

1

5

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?

Groundless answered 26/4, 2011 at 17:45 Comment(0)
R
13

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.

Resurrectionism answered 27/4, 2011 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.