wicked_pdf icon indicating copy to clipboard operation
wicked_pdf copied to clipboard

wkhtmltopdf-binary v0.12.4 screws sizes of page and fonts

Open pastullo opened this issue 6 years ago • 6 comments

I just had a fresh install of wicked_pdf and wkhtmltopdf gems and the dimension of the fonts were really not right. Downgraded from gem 'wkhtmltopdf-binary','0.12.4' to gem 'wkhtmltopdf-binary','0.12.3' and the A4 page is just right again.

I know this is not a wicked_pdf problem, but considering how many people will be installing the latest version of wkhtmltopdf this might help somebody!

pastullo avatar Nov 15 '18 17:11 pastullo

Thank you for the notes!

yxshu11 avatar Nov 22 '18 09:11 yxshu11

See https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3241#issuecomment-401995296

For 0.12.4 you can set the dpi and zoom levels to fix this.

rileys avatar Apr 20 '19 19:04 rileys

Better than that, use this as an initialiser:

WickedPdf.config[:disable_smart_shrinking] = true

brendon avatar Jun 26 '19 00:06 brendon

WickedPdf.config[:disable_smart_shrinking] = true did not work for me WickedPdf.config[:lowquality] = true did.

jsugarman avatar Sep 19 '19 15:09 jsugarman

I can confirm similar screwage at v0.12.5/6 (binary / patched qt), dropping in the standard (deb) package (via apt install) works well, but introduces the lack of some features; in my case, the absence of disable_smart_shrinking option.

Since the zoom option didn't seem to work at all, I worked around the "smart shrinking" by two HTML/CSS additions:

  • style="zoom: 2;" on body — or whatever value that is sure to require the "smart shrinking"
  • a transparent style="position: absolute; width: <REQUIRED-PAGE-WIDTH>mm" div with that body

and it worked quite well — in my case, with margins set to 0 — I'm sure margins can be supported in a similar fashion.

I've refrained from adding another issue to 1.2K of wkhtmltopdf's, but, for the benefit of RoR crowd, I think this kind of info should be included with the README.

costa avatar Oct 01 '21 17:10 costa

A zoom of around 1.3 worked for me.

DaAwesomeP avatar Jan 10 '22 05:01 DaAwesomeP