Reputation: 7483
I got pdfkit install and even set up wkhtmltopdf installed as well however I'm getting the following error everytime I try to create a pdf.
PDFKit::NoExecutableError
No wkhtmltopdf executable found at bundler: command not found: which
Install missing gem executables with `bundle install`
>> Please install wkhtmltopdf - https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF
My Gemfile has the following:
gem 'jquery-rails'
gem 'devise'
gem 'carrierwave'
gem "wkhtmltopdf"
gem 'pdfkit'
And my application.rb has the following entry:
config.middleware.use "PDFKit::Middleware", :print_media_type => true
am I missing something here - I've run a bundle install but still get this error everytime I try to create a pdf. Please help
Upvotes: 4
Views: 8892
Reputation: 1728
None of the above worked for me. I tried the solution posted in here https://github.com/pdfkit/pdfkit/issues/123
Upvotes: 0
Reputation: 89
Ali,
I don't see you mention which operating system you're on. Fl00r, and I, are both assuming that it's a Linux system, so adjust accordingly. This is what I needed to do to make PDFKit work with wkhtmltopdf for my Rails application running on 64-bit Ubuntu 12.04 LTS.
Remove any reference to wkhtmltopdf
or wkhtmltopdf-binary
from your Gemfile
.
Add only gem 'pdfkit', :require => 'pdfkit'
to your Gemfile
In your config/initializers/mime_types.rb
file add
Mime::Type.register "application/pdf", :pdf
Remove any config/initializers/pdfkit.rb
file
Uninstall the gems from the server that you're running the Rails application on
gem uninstall wkhtmltopdf -a
gem uninstall wkhtmltopdf-binary -a
Download to your server wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
from the project download site here. There is a bug in the latest suggested download versions that prevent a user from being able to select and copy text from a generated PDF, but this version doesn't have that bug. This issue is referenced at http://code.google.com/p/wkhtmltopdf/issues/detail?id=886
Extract the executable from the tar archive
tar -xvf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
Move it to the /usr/local/bin/
directory
sudo mv wkhtmltopdf-0.10.0.rc2 /usr/local/bin/
Now setup a symbolic link to the file so it's easy to upgrade at a later point
sudo ln -s /usr/local/bin/wkhtmltopdf-0.10.0.rc2 /usr/local/bin/wkhtmltopdf
Set the permissions on the file
sudo chmod 755 /usr/local/bin/wkhtmltopdf-0.10.0.rc2
After doing all of this, and restarting my server, PDFKit will now use the wkhtmltopdf that I have installed on the server.
Caveat: On one occasion my Rails application started reporting that it couldn't find the wkhtmltopdf executable in the path, not sure why as nothing changed. Restarting the server corrected this issue.
Upvotes: 2
Reputation: 83680
You should read Install readme here:
so you need to install wkhtmltopdf manualy:
https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF
or like this
gem install wkhtmltopdf-binary
PS
check which wkhtmltopdf
and create new file config/initializers/pdfkit.rb
PDFKit.configure do |config|
config.wkhtmltopdf = 'PATH/TO/wkhtmltopdf'
end
Upvotes: 6