wicked_pdf
wicked_pdf copied to clipboard
wkhtmltopdf-binary v0.12.4 screws sizes of page and fonts
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!
Thank you for the notes!
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.
Better than that, use this as an initialiser:
WickedPdf.config[:disable_smart_shrinking] = true
WickedPdf.config[:disable_smart_shrinking] = true
did not work for me
WickedPdf.config[:lowquality] = true
did.
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;"
onbody
— or whatever value that is sure to require the "smart shrinking" - a transparent
style="position: absolute; width: <REQUIRED-PAGE-WIDTH>mm"
div
with thatbody
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.
A zoom of around 1.3
worked for me.