Generating a pdf without any styling reduces the font-size by 4%. Is there any issue with WICKED_PDF gem?
Example
pdf = WickedPdf.new.pdf_from_string(
'<div style="font-family: Open Sans; font-size:9px;">1234567890_9 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:10px;">1234567890_10 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:10.4px;">1234567890_10.4 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:10.5px;">1234567890_10.5 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:11px;">1234567890_11 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:12px;">1234567890_12 Font Size Issue </div>',
{ disable_smart_shrinking: true }
)
When i generated a pdf with above font sizes the rendered pdf font size got shrunk by 4 percent.
Result when checked the pdf in Adobe Acrobat viewer:
1) 8.64
2) 9.6
3) 9.6
4) 10.56
5) 10.56
6) 11.52
I used font family as 'Open-Sans' and different font sizes
whats wrong here??
WickedPDF isn't adding or changing how your PDF is rendered, however it depends on the wkhtmltopdf command-line utility, which has historically had problems with precise accuracy, and can also have differences due to monitor resolution or fonts installed where the rendering happens (which means you should check production as well as development, if for instance, you develop on a mac with a retina screen, and deploy on linux with an open font package installed).
Here's a long thread with some good suggestions, such as specifying dpi:
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3241
It may also help to wrap your divs in a valid HTML document, including DOCTYPE.
Please come back and update this issue if you find a good solution for your case! Lots of people see these and will benefit from your findings.
I have gone through the thread discussion you have mentioned, but i am still seeing the issue. I tried varying dpi but it didn't work
Hi saipraveen..I'm encountering the same problem..did you find a soolution?
No @ciaranc78, i did not find any solution
Does changing the zoom level help?
pdf = WickedPdf.new.pdf_from_string(
'<div style="font-family: Open Sans; font-size:9px;">1234567890_9 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:10px;">1234567890_10 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:10.4px;">1234567890_10.4 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:10.5px;">1234567890_10.5 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:11px;">1234567890_11 Font Size Issue </div>
<div style="font-family: Open Sans; font-size:12px;">1234567890_12 Font Size Issue </div>',
{ disable_smart_shrinking: true, zoom: 1 } # or maybe `zoom: 1.04`
)
Thanks for the suggestion unixmonkey, it turns out I had inadvertently upgraded to the latest version of the gem.. reverting to previous version sorted it!
Same here! To clarify a bit, wkhtmltopdf-binary (0.12.4.0) seems to be the culprit, and downgrading to 0.12.3.1 "fixes" the problem.
Most helpful comment
Same here! To clarify a bit, wkhtmltopdf-binary (0.12.4.0) seems to be the culprit, and downgrading to 0.12.3.1 "fixes" the problem.