【问题标题】:Wicked_pdf multiple pdf's one same pageWicked_pdf 多个 pdf 的同一页
【发布时间】:2018-08-17 21:38:40
【问题描述】:

是否可以使用 wicked_pdf 在一个页面上有多个 pdf 链接?我似乎找不到这方面的任何信息。

例如,我有一份每日销售报告和一份每周销售报告,我希望在展示页面上以 pdf 格式下载。

控制器

format.pdf do
 render pdf: "#{@sales.name}", 
 template: 'trials/sales_day_report',
 disposition: 'attachment'
end
format.pdf do
 render pdf: "#{@sales.name}", 
 template: 'trials/sales_weekly_report',
 disposition: 'attachment'
end

显示

<%= link_to 'Download Daily Report', sale_path(format: 'pdf') %>
<%= link_to 'Download Weekly Report', sale_path(format: 'pdf') %>

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-5 wicked-pdf


    【解决方案1】:

    你需要像这样在你的链接中传递一个额外的参数:

    <%= link_to 'Download Daily Report', sale_path(format: 'pdf', sale_type: 'daily') %>
    <%= link_to 'Download Weekly Report', sale_path(format: 'pdf', sale_type: 'weekly') %>
    

    然后,在您的 pdf 模板路由中插入该参数:

    format.pdf do
      render pdf: "#{@sales.name}",
      template: "trials/sales_#{params[:sale_type]}_report",
      disposition: 'attachment'
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多