I can create a PDF document using PRAWN, but when I try to download as an attachment via a link, nothing appears to happen. When I go into the /tmp/pdfs/ directory of my rails app, I can see the created PDF document. Can anyone see why the pdf doc will not download? Thanks, Frank VIEW =====Download to PDF<br> <%= link_to_remote image_tag("/images/icons/download_to_pdf.jpg"), :url => {:controller => "reports", :action => "make_pdf"} %> ===== CONTROLLER ===== def make_pdf filename = ''prawn.pdf'' pdf = Prawn::Document.new pdf.text("Prawn Rocks") pdf.render_file(''tmp/pdfs/prawn.pdf'') send_file "#{RAILS_ROOT}/tmp/pdfs/#{filename}", :type => ''application/pdf'', :disposition => ''attachment'' end =====-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/5 Frank Kany <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> I can create a PDF document using PRAWN, but when I try to download as > an attachment via a link, nothing appears to happen. When I go into the > /tmp/pdfs/ directory of my rails app, I can see the created PDF > document. > > Can anyone see why the pdf doc will not download? > > Thanks, > > Frank > > VIEW > =====> Download to PDF<br> > <%= link_to_remote image_tag("/images/icons/download_to_pdf.jpg"), :url > => {:controller => "reports", :action => "make_pdf"} %> > =====> > CONTROLLER > =====> def make_pdf > filename = ''prawn.pdf'' > > pdf = Prawn::Document.new > pdf.text("Prawn Rocks") > pdf.render_file(''tmp/pdfs/prawn.pdf'') > > send_file "#{RAILS_ROOT}/tmp/pdfs/#{filename}", :type => > ''application/pdf'', :disposition => ''attachment'' > endHave you checked the html of the page to see if the link looks correct (View, Page Source or similar in your browser). If it does look ok does it work if you type it into browser directly? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 5, 2:29 pm, Frank Kany <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I can create a PDF document using PRAWN, but when I try to download as > an attachment via a link, nothing appears to happen. When I go into the > /tmp/pdfs/ directory of my rails app, I can see the created PDF > document.Because you''ve got a link_to_remote - that just creates a Ajax.Request object that fetches the data and then ignores it - use a regular link. Fred> > Can anyone see why the pdf doc will not download? > > Thanks, > > Frank > > VIEW > =====> Download to PDF<br> > <%= link_to_remote image_tag("/images/icons/download_to_pdf.jpg"), :url > => {:controller => "reports", :action => "make_pdf"} %> > =====> > CONTROLLER > =====> def make_pdf > filename = ''prawn.pdf'' > > pdf = Prawn::Document.new > pdf.text("Prawn Rocks") > pdf.render_file(''tmp/pdfs/prawn.pdf'') > > send_file "#{RAILS_ROOT}/tmp/pdfs/#{filename}", :type => > ''application/pdf'', :disposition => ''attachment'' > end > =====> -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That worked Fred. Thank you both for your help. Frederick Cheung wrote:> On Jan 5, 2:29�pm, Frank Kany <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> I can create a PDF document using PRAWN, but when I try to download as >> an attachment via a link, nothing appears to happen. �When I go into the >> /tmp/pdfs/ directory of my rails app, I can see the created PDF >> document. > > Because you''ve got a link_to_remote - that just creates a Ajax.Request > object that fetches the data and then ignores it - use a regular link. > > Fred-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.