I'm using the prawn-rails gem to generate a pdf and am setting the filename by overwriting the @filename
variable in my controller eg:
respond_to do |format|
format.pdf do
@filename = "NewReportName.pdf"
render 'report'
end
end
I am then using the following view to generate the pdf:
data_rows = [@report.fields.map{|f| f.titleize }]
@report.results.each do |result|
data_rows << @report.fields.map{|k| result.send(k) }
end
prawn_document() do |pdf|
pdf.table(data_rows)
end
The pdf generation works in all browsers I've tested however when you go to save the pdf in IE11, it sets the filename to be the action name instead of the name specified in the @filename
variable.
I've posted a comment on the git repo for the prawn-rails gem but I'm wondering if anyone here could help. Thanks in advance.
render 'report', disposition: 'attachment', filename: @filename
... Not 100% sure about the syntax, but you get the idea... - Ruby Racerresponse.headers['Content-Disposition'] = "attachment; filename=\"NewReportName.pdf\""
- chrisgooley