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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With