문제

I'm having this error when I try to use wicked_pdf:

irb: No such file or directory - which wkhtmltopdf
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.chomp
        from C:/Ruby187/lib/ruby/gems/1.8/gems/wicked_pdf-0.7.2/lib/wicked_pdf.r
b:19:in `initialize'
        from (irb):2:in `new'
        from (irb):2
        from :0

I think the path to wkhtmltopdf should be configured. But how?

도움이 되었습니까?

해결책

According to the sources, simply add it to your $PATH (the folder containing the binary).

다른 팁

Provide sth like

:wkhtmltopdf => '/usr/local/bin/wkhtmltopdf', # path to binary

with your render call and make sure, that a wkhtmltopdf binary resides at that path. (You can get wkhtmltopdf from google code in case you have not installed it yet)

Wkhtmltopdf project can't be found on Google Code any longer. It was moved to http://wkhtmltopdf.org/downloads.html

In my case, I just had to download the OSX binary and it was automatically added to my PATH variable.

Create an initializer: config/initializers/wicked_pdf.rb:

WickedPdf.config = {
  :exe_path => "#{ENV['GEM_HOME']}/bin/wkhtmltopdf"
}

:exe_path should hold the path to the wkhtmltopdf binary. For my instance, I used the gem:

gem "wkhtmltopdf-binary"

Which stored the binary in my GEM_HOME, so I could reference a path that wasnt hard coded.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top