我正在尝试使用以下工具生成PDF
WIckedPdf版本= 1.1.0
wkhtmltopdf 0.12.4 (带有修补的qt)
Rails 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。
任何帮助/参考都将是非常有帮助和感激的
发布于 2018-10-19 08:21:20
设置dpi: 300
可以解决内容呈现过小的问题。
发布于 2018-09-28 23:27:04
我也有同样的问题,我可以通过在wicked_pdf配置文件中添加lowquality: true
来修复它。
在config/wicked_pdf.rb
文件中
WickedPdf.config = {
#cross enviroment configs
}
if Rails.env.development?
WickedPdf.config[:lowquality] = true
end
制片人和参考:Issue #754
发布于 2018-07-24 22:07:58
您可以在视图模板中添加CSS类,以像普通HTML一样增加字体大小。
https://stackoverflow.com/questions/51499872
复制相似问题