Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Problem getting PDF from Prawn
4 Posts
Problem getting PDF from Prawn


I'm using Rails 2.0.2 and Ruby 1.8.7 for my project. When I generate a simple PDF with Prawn it will be saved in the Rails_Root. What can I do to get it displayed in the brwoser or downloaded?

Thx, Sandra


To display pdfs you'll want to create a view template with extension .pdf.prawn (eg. show.pdf.prawn)

In the corresponding action you then want to respond_to pdf just like you would any other format.

When linking to this file: link_to( "click me", model_path(@model, :format => :pdf ) )

Hope that helps?


Thanks for your answer Gavin,

No, it don't helps because I did forget to mention that I do not use Prawnto (because a higher version of rails would be necessary). Or how do I have to name the template?

Any other suggestion?

Thx, Sandra

Sorry Sandra,

I had assumed you were using Prawnto.

Which version of Rails are you using?

I'm not sure what the issue is with Prawnto and Rails version but why not try to unpack the plugin files to your /lib directory and then run them.

Rails should give you concise enough error messages that you can work out where the issues are and correct them?

Another approach would be to create the .pdf file and use the send_file method to download it to your user?


4 Posts
Login to add your message