Rails PDF Generation with Prawn in IE7

Posted by fluid_chelsea on Stack Overflow See other posts from Stack Overflow or by fluid_chelsea
Published on 2009-10-15T18:09:49Z Indexed on 2010/04/09 11:23 UTC
Read the original article Hit count: 571

I'm using Prawn and Prawnto to generate a PDF in a Ruby on Rails app (Rails version 2.2.2) which works great and generates PDFs happily and sends them to the user to download in Firefox.

The problem is in IE7.

I have a route set up like so:

map.invoice_pdf '/invoices.pdf', :controller => 'invoices', 
                :action => 'index', :format => 'pdf'

Which I then have a link like so to call:

invoice_pdf_path(:year => params[:year], :month => params[:month], 
                 :unpaid_only => params[:unpaid_only])

And the following in my controller:

 def index
    params[:year]  = default params[:year]
    params[:month] = default params[:month]
    params[:page] ||= 1

    @invoices = Arobl.find_invoices_for_customer(current_customer.strCustomerID,
                       params)

    respond_to do |format|
      format.html{ render :action => 'index' }
      format.pdf{
        prawnto :inline => false, :filename => 
                "#{current_customer.strCustomerID}_invoice.pdf"
  end

In FF this works as expected, when the link is clicked the show action is invoked with a format of .pdf, and responds with the correctly named PDF. When it's hit with IE7 it says that the file or website could not be found, and references "invoices.pdf" instead of the expected customer_id_invoice.pdf filename.

Any idea what could be causing this behaviour?

Thanks!

© Stack Overflow or respective owner

Related posts about prawn

Related posts about ruby-on-rails