邪恶的PDF RuntimeError

时间:2014-10-17 10:34:51

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

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

  

ClientsController#show中的RuntimeError

     

错误:执行失败:[" C:/ Program Files / wkhtmltopdf / bin / wkhtmltopdf.exe"," - 页脚中心","中心&# 34;," - 页脚左","左"," - 页脚右","右",&#34 ; 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

2 个答案:

答案 0 :(得分:0)

我遇到了同样的错误并按照此处的指示修复了

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

即我通过将gemfile条目更改为:

切换到gem的临时修复
gem 'wicked_pdf', github: 'mileszs/wicked_pdf'

我认为它与使用file://而不是file:///。

有关

答案 1 :(得分:0)

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