Hello,
I am trying to generate PDF using
WIckedPdf version = 1.1.0
wkhtmltopdf 0.12.4 (with patched qt)
Below is my Controller endpoint
@cover = render_to_string layout: "application.html.erb", template: "pdf/cover.html.erb", locals: {report: @report}
@pdf = render_to_string pdf: "report",
encoding: "UTF-8",
page_size: 'A4',
layout: "pdf.html.erb",
orientation: 'Portrait',
disable_smart_shrinking: false,
disable_internal_links: false,
disable_external_links: false,
lowquality: false,
background: true,
no_background: false,
page_height: 297,
page_width: 210,
cover: @cover,
template: "pdf/report.pdf.erb",
locals: {report: @report},
show_as_html: false,
margin: {
bottom: 40,
top: 10
},
footer: {
html: {
template: 'pdf/footer.html.erb' # use :template OR :url
}
},
toc: {
text_size_shrink: 0.8,
header_text: "Table of Contents",
no_dots: false,
disable_dotted_lines: false,
disable_links: false,
disable_toc_links: false,
disable_back_links: false,
}
send_data @pdf, type: :pdf, disposition: 'inline'
Am facing the problem that All the text that are generated in pdf is very very SMALL. To achieve font size of 14 in pdf, i had to change my css as font-size: 56px (Four times than the normal pixel)
Can Anybody help me why font size is rendered like this? Also, All the css that includes pixels such as padding, margin are four times smaller than normal.
Even if changed CSS of my file to four times higher values, CURRENTLY I AM UNABLE TO CHANGE FONT_SIZE FOR TABLE OF CONTENTS GENERATED.
Any help / Reference would be highly helpful and appreciated
This is a known issue with wkhtmltopdf 0.12.4 documented here with a few workarounds like setting:
lowquality: true,
Or playing around with these values (and remember to check both dev and prod environments, as they can differ):
zoom: 1.28,
dpi: 75
Alternately, you can try upgrading to 0.12.5, which this issue is supposed to be fixed, or downgrading to 0.12.3 if necessary.
Let me know what you try and how it goes!
Hi @unixmonkey ,
Thanks a lot for your instant response.
I did not try your first workaround, But I tried upgrading towkhtmltopdf 0.12.5 It fixed my font size issue, But it produced another issue that Table of Contents not being generated in view.
Whereas, Downgrading to wkhtmltopdf 0.12.3 fixed my issues and working perfectly fine.
Most helpful comment
This is a known issue with
wkhtmltopdf 0.12.4documented here with a few workarounds like setting:Or playing around with these values (and remember to check both dev and prod environments, as they can differ):
Alternately, you can try upgrading to 0.12.5, which this issue is supposed to be fixed, or downgrading to 0.12.3 if necessary.
Let me know what you try and how it goes!