0

正如标题所说,我使用运行良好的 Rails gem,但我想将 pdf 单独保存到一个文件夹中。有没有办法在不调用 render_pdf 的情况下做到这一点?

这是行不通的:

  render_pdf :template => 'caseprinttemplates/create_pdf_to_print.erb', :pdf_file => "/home/mattias/www/Inkasso/public/uploadedfiles/" + results[:title]

  redirect_to new_interventionreminder_path(:case_id => @interventionreminder.case_id, :saved => "1")
  return

这确实适用于另一个页面:

render_pdf :template => 'caseprinttemplates/create_pdf_to_print.erb', :layout => nil, :send_file => { :filename => "samladutskrift.pdf"}
4

1 回答 1

0

act_as_flying_saucer 插件只是 Flying Saucer java 库的一个包装器。在源代码中,您可以看到只定义了一个包装器方法:render_pdf()。

https://github.com/dagi3d/acts_as_flying_saucer/blob/master/lib/acts_as_flying_saucer_controller.rb

但是,您可以使用 render_pdf() 渲染到文件,如此处找到的示例

# Renders the template located at '/foo/bar/pdf.html.erb' and stores the pdf 
# in the temp path with a filename based on its md5 digest
render_pdf :file => '/foo/bar/pdf.html.erb'

# renders the template located at 'app/views/foo.html.erb' and saves the pdf
# in '/www/docs/foo.pdf'
render_pdf :template => 'foo', :pdf_file => '/www/docs/foo.pdf'

# renders the 'app/views/foo.html.erb' template, saves the pdf in the temp path
# and sends it to the browser with the name 'bar.pdf'
render_pdf :template => 'foo', :send_file => { :filename => 'bar.pdf' }
于 2012-01-26T18:26:16.680 回答