Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top