Unable to create pdf files using pdfkit - PDFKit :: NoExecutableError

I have pdfkit installed and even wkhtmltopdf installed, but I get the following error every time I try to create a pdf file.

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 application has the following entry:

 config.middleware.use "PDFKit::Middleware", :print_media_type => true 

I am missing something here - I started installing the package, but I still get this error every time I try to create a pdf file. Please, help

+4
source share
3 answers

Here's the Install readme:

https://github.com/jdpace/PDFKit

so you need to install wkhtmltopdf manualy:

https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF

or how is it

 gem install wkhtmltopdf-binary 

PS

check which wkhtmltopdf

and create a new config / initializers / pdfkit.rb file

 PDFKit.configure do |config| config.wkhtmltopdf = 'PATH/TO/wkhtmltopdf' end 
+6
source

Ali

I do not see you mention which operating system you are on. Fl00r and I both assume this is a Linux system, so configure accordingly. This is what I needed to make PDFKit work with wkhtmltopdf for my Rails application running on 64-bit Ubuntu 12.04 LTS.

Remove any link 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 

Delete any config/initializers/pdfkit.rb file

Remove gems from the server running the Rails application on

 gem uninstall wkhtmltopdf -a gem uninstall wkhtmltopdf-binary -a 

Download wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 from the project download site here . There is an error in the latest download versions that prevents the user from selecting and copying text from the generated PDF document, but this version does not have this error. This problem is mentioned in http://code.google.com/p/wkhtmltopdf/issues/detail?id=886

Extract executable file from tar archive

 tar -xvf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 

Move it to the /usr/local/bin/

 sudo mv wkhtmltopdf-0.10.0.rc2 /usr/local/bin/ 

Now configure a symbolic link to the file to simplify its updating in the future.

 sudo ln -s /usr/local/bin/wkhtmltopdf-0.10.0.rc2 /usr/local/bin/wkhtmltopdf 

Set permissions for the file

 sudo chmod 755 /usr/local/bin/wkhtmltopdf-0.10.0.rc2 

After doing all this and restarting my server, PDFKit will now use wkhtmltopdf, which I installed on the server.

Caution: one day the Rails application started reporting that it could not find the wkhtmltopdf executable in the path, not sure why, because nothing had changed. This problem has been restarted by the server.

+2
source

None of this helped me. I tried the solution posted here https://github.com/pdfkit/pdfkit/issues/123

0
source

Source: https://habr.com/ru/post/1400172/


All Articles