【发布时间】:2016-11-23 19:54:26
【问题描述】:
我正在尝试使用 wicked 和 Rails API 创建可下载的 PDF。目前只能下载PDF,但内容为空,文件名为response.pdf.pdf。
当对特定分数发出 GET 请求时,这是我用来生成 PDF 的方法。
def download_pdf(score)
html = render_to_string(:action => :show, :layout => "pdf.html.erb", :template => "scores/show.pdf.erb", locals:{:score => score})
pdf = WickedPdf.new.pdf_from_string(html)
send_data(pdf,
:filename => 'test.pdf',
:disposition => 'attachment')
end
【问题讨论】:
标签: ruby-on-rails pdf rails-api wicked-pdf