首页 > 解决方案 > Wicked_pdf 目录文本大小非常小

问题描述

我正在尝试使用生成 PDF

WIckedPdf 版本 = 1.1.0

wkhtmltopdf 0.12.4(带有补丁的qt)

导轨 4.2

下面是我的控制器端点

@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'

我面临的问题是 pdf 中生成的所有文本都非常小。为了在 pdf 中实现 14 的字体大小,我不得不将我的 css 更改为 font-size: 56px (是正常像素的四倍)

任何人都可以帮我为什么字体大小是这样呈现的吗?此外,包括填充、边距等像素的所有 css 都比正常小四倍。

即使将我的文件的 CSS 更改为高四倍的值,目前我也无法更改生成的目录的 FONT_SIZE。

任何帮助/参考都会非常有帮助和赞赏

标签: ruby-on-railspdf-generationwkhtmltopdfruby-on-rails-4.2wicked-pdf

解决方案


设置dpi: 300应该可以解决内容渲染过小的问题。


推荐阅读