lamrin
lamrin

Reputation: 1441

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_file('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

Upvotes: 0

Views: 930

Answers (2)

Lance Gleason
Lance Gleason

Reputation: 24

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

Upvotes: 0

Miki
Miki

Reputation: 7188

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.

Upvotes: 4

Related Questions