【问题标题】:Wicked PDF RuntimeError邪恶的 PDF 运行时错误
【发布时间】:2014-12-12 22:15:19
【问题描述】:

我已经在 rails 4 上安装了 Wicked PDF,现在我遇到了这个问题:

ClientsController#show 中的 RuntimeError

错误:执行失败:["C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe", "--footer-center", "Center", "--footer-left", "Left", “--footer-right”、“右”、“file://C:/Users/Rashid/AppData/Local/Temp/wicked_pdf20141017-9664-18xoryq.html”、“C:/Users/Rashid/AppData/Local /Temp/wicked_pdf_generated_file20141017-9664-zo89le.pdf"] 错误:无法生成 PDF!命令错误:加载页面 (1/6) [>] 0% [======>] 10% 错误:加载页面文件失败://c/Users/Rashid/AppData/Local/Temp/wicked_pdf20141017-9664 -18xoryq.html(有时它会使用 --load-error-handling ignore 忽略此错误)由于网络错误退出代码 1:ContentNotFoundError

def show
respond_to do |format|
  format.html
  format.pdf do
    @example_text = "some text"
    render :pdf => "file_name",
           :template => 'clients/show.pdf.erb',
           #:layout => 'pdf',
           :footer => {
               :center => "Center",
               :left => "Left",
               :right => "Right"
           }
  end
 end
end

【问题讨论】:

  • 你在 gemfile 中添加了gem "wkhtmltopdf-binary" 吗?如果没有,则添加并运行bundle install
  • @Gagan Gami 是的,我做到了。

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


【解决方案1】:

我遇到了同样的错误,并按照此处的说明进行了修复

https://github.com/mileszs/wicked_pdf/issues/157

也就是说,我通过将 gemfile 条目更改为:

gem 'wicked_pdf', github: 'mileszs/wicked_pdf'

我认为这与使用 file:// 而不是 file:/// 有关。

【讨论】:

    【解决方案2】:

    path/to/gem/wkhtmltopdf/bin 中查找wicked_pdf.rb,在第64 行将file:// 替换为file:///

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多