Search code examples
ruby-on-railsrubywkhtmltopdfwicked-pdf

wkhtmltopdf shrinks the input, which was fine in the older version


We use wkhtmltopdf to generate PDF from html and when upgraded from 0.12.3 to 0.12.6, we noticed that the PDFs generated were in different resolutions. Unfortunately, the viewport-size, or dpi did not help in fixing the problem.

Tried to downgrade to older version, but that's a crude way to go deprecated soon. So, dpi / viewport-size seems to have also failed us. Finally, found zoom and adjusted the level to 1.25-1.3 times. I know this is never going to help across the different kinds of PDFs that are generated.

Any help here will be much appreciated. Thanks!


Solution

  • Turns out, after 0.12.4 version, wkhtmltopdf auto computes resolution for the pdf based on the dpi and web-driver. To get back to the legacy pdf export, we need to use --disable-smart-shrinking. ref: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/5056