简体   繁体   English

在Rails 4.0中使用对虾导轨为pdf设置文件名在IE11中不起作用

[英]Setting the filename for a pdf using prawn-rails in rails 4.0 doesn't work in IE11

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: 我正在使用prawn-rails gem生成pdf,并通过覆盖控制器中的@filename变量来设置文件名,例如:

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: 然后,我使用以下视图生成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. pdf生成可在我测试过的所有浏览器中使用,但是当您将pdf保存在IE11中时,它将文件名设置为操作名称,而不是@filename变量中指定的名称。

I've posted a comment on the git repo for the prawn-rails gem but I'm wondering if anyone here could help. 我在git repo上发布了对虾栏宝石的评论,但我想知道这里是否有人可以提供帮助。 Thanks in advance. 提前致谢。

You can set the file name using prawnto 您可以使用prawnto设置文件名

format.pdf do
  @filename = "NewReportName.pdf"
  prawnto :filename=>@filename
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM