All my layouts that looked great before are now messed up, appears to be rendering with a different and smaller font after upgrading WKHTMLTOPDF
. Full-width divs are also rendering smaller than before.
I've tried modifying the dpi flag in wicked, I saw a small difference, when set to dpi: 300
, but the difference didn't seem to remedy the issue, no matter the change to dpi
. Anyone have any hints? Pretty sure the issue is with changes made to WKHTMLTOPDF
.
We had these versions locked in for a while, as the rendered PDFs looked great:
wicked_pdf (1.1.0)
wkhtmltopdf-binary (0.9.9.3)
(Rendered using the font NimbusSansL Bold & Regular)We have a new feature that requires better handling of page-breaks in long tables. Page-breaks are working great now that we've upgraded, but now we have more issues, here are the new versions:
wicked_pdf (1.2.2)
wkhtmltopdf-binary (0.12.4)
(Now rendering with the font, DejaVuSans, Bold & Regular)Code for rendering:
respond_to do |format|
format.html
format.pdf do
render pdf: 'report',
template: 'download_report.pdf.erb',
show_as_html: params[:debug].present?,
layout: 'report_application.pdf',
margin: {
top: 5,
bottom: 5,
left: 5,
right: 5
}
end
end
Adding the zoom
option seemed to fix the majority of my layout issues. The affected divs have and require pixel width defined. I determined the amount of zoom by resizing one of the divs back to its previous, rendered, size. Divide the new width by the old width to get your zoom:
respond_to do |format|
format.html
format.pdf do
render pdf: 'report',
zoom: 1.27,
template: 'download_report.pdf.erb',
show_as_html: params[:debug].present?,
layout: 'report_application.pdf',
margin: {
top: 5,
bottom: 5,
left: 5,
right: 5
}
end
end