我在用邪恶_pdf https://github.com/mileszs/wicked_pdf用于生成pdf
from html
在我的 Rails 项目上。正在渲染template
但我无法打印header/footer
部分。下面是我的仅打印的代码template
section
render pdf: "pdf_name",
layout: 'application',
template: 'reports/show',
formats: [:html],
margin: { top: 10, bottom: 10, left: 10, right: 10 },
disable_javascript: true,
show_as_html: params[:debug],
header: {
html: { template: 'shared/header' },
spacing: 10
},
footer: {
html: { template: 'shared/footer' },
spacing: 30,
line: true
}
如果我尝试使用WickedPdf.new.pdf_from_string render_to_string
它显示Failed to load PDF document
错误甚至很简单WickedPdf.new.pdf_from_string('<html><body><h1>Hello There!</h1></body></html>')
不起作用。
我尝试过使用render_to_string_with_wicked_pdf, render_with_wicked_pdf
但没有成功。我的 Rails 版本是3.2.19
, wicked_pdf
宝石版本是1.1.0
and wkhtmltopdf
版本是wkhtmltopdf-0.13.0-alpha-7b36694_linux-trusty-amd64.deb
。我也尝试使用wkhtmltopdf
版本0.12.0
.
我的问题是
- 为什么我的上述实现不起作用?
- Why
pdf_from_string
不起作用?
任何形式的帮助表示赞赏。谢谢。