开发者

How to generate PDF that is returned to the client using the Prawn gem

i am using prawn gem to generate pdf file,

pdf.render_fi开发者_JAVA技巧le('csv.pdf') is saving the file to the project root

instead i want to open the pdf before saving to root, then save it to any location

how to go about it??

thanks


Try in the controller:

respond_to do |format|
  format.pdf do
    `send_data your_pdf.render, :filename=>"default_filename.pdf", :type=>"application/pdf"`
  end
end

where your_pdf is the object you created with Prawn.


You could also user prawnto with the inline => false option.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜