Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: wkhtmltopdf RuntimeError (Location of wkhtmltopdf unknown)

I am using Ubuntu 11.04 to develop an app in Ruby on Rails. In the app I need to generate pdf documents. So I am using the wicked_pdf and wkhtmltopdf-binary gems.

In the development environment in my system everything is working fine. But once I deployed the app in production on CentOS 5.6 using Phusion Passenger, when I try to generate pdfs on the fly its giving me the following error:

RuntimeError (Location of wkhtmltopdf unknown)

I am using Ruby1.9.2.p136 Rails 3.1.1

Any help will be much appreciated....Thanks.

like image 930
dbaruah Avatar asked Oct 11 '11 09:10

dbaruah


3 Answers

An alternative is to install the binary via the Gemfile.

Just add the following line to your production group:

gem 'wkhtmltopdf-binary'

That should add binary support for linux-i386, amd64, and darwin.

And then run

bundle install --without development test

to install the gem in a production environment. After which, you just restart your server.

That's all.

I hope this helps

like image 185
Skully Avatar answered Oct 04 '22 01:10

Skully


do you use static wkhtmltopdf binary? i downloaded it here and extraced it to /path/to/rails_app/bin

and add it to rails like this:

#config/initializers/wicked_pdf.rb
WickedPdf.config = {
  :exe_path => Rails.root.join('bin', 'wkhtmltopdf-i386').to_s,
}
like image 35
ben Avatar answered Oct 04 '22 03:10

ben


for mac os - x you should install wkhtmltopdf by homebrew

$ brew tap homebrew/boneyard # the wkhtmltopdf formula is now inactive but still available in the boneyard repository 
$ brew install wkhtmltopdf
like image 43
Hannes Avatar answered Oct 04 '22 01:10

Hannes