wkhtmltopdf / wkhtmltopdf

Convert HTML to PDF using Webkit (QtWebKit)
https://wkhtmltopdf.org
GNU Lesser General Public License v3.0
13.98k stars 1.82k forks source link

converting html file with high resolution images to pdf is slow #4978

Open aren5a opened 3 years ago

aren5a commented 3 years ago

I have a simple html file with js code or anything, it does have 6 images in the html Images info: Image Size: 3024x4032 Megapixels: 12.2 the process to convert to pdf takes about 40 seconds which its a long time, is there anything I can do to make it preform faster?

PhilterPaper commented 3 years ago

Have you tried using a photo editor (PhotoShop, GIMP, etc.) to rescale the images to something much closer to their final size? You probably want to be a little larger, so you don't end up having to enlarge the scaled image (which loses resolution).

aren5a commented 3 years ago

@PhilterPaper the images are uploaded to the blob storage through the app via code, its a webpage in my app that I save it to an html and then convert it to pdf. If I have to do that I should write a code to resize the images when want to convert the html page to pdf, and was hoping there is a another solution.

PhilterPaper commented 3 years ago

Well, I'm pretty sure that just handling such large images is slower than handling small ones, and if there is any raster image conversion going on that will be slower, and you will pay the price in either rescaling during wkHTMLtoPDF or in a bloated PDF file size (if it stores the entire original). I would suggest that you compare speeds (and quality) for one test case (manually rescaling the images) and see if it might be worth scaling down the images with some automated process (keeping in mind that the rescale process itself will cost time). Good luck!