无法使用pdfkit创建pdf - PDFKit :: NoExecutableError

Ali*_*Ali 4 ruby pdfkit wkhtmltopdf ruby-on-rails-3

我得到了pdfkit安装,甚至安装了wkhtmltopdf,但是每当我尝试创建一个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
Run Code Online (Sandbox Code Playgroud)

我的Gemfile有以下内容:

gem 'jquery-rails'
gem 'devise'
gem 'carrierwave'
gem "wkhtmltopdf"
gem 'pdfkit'
Run Code Online (Sandbox Code Playgroud)

我的application.rb有以下条目:

config.middleware.use "PDFKit::Middleware", :print_media_type => true
Run Code Online (Sandbox Code Playgroud)

我在这里遗漏了一些东西 - 我已经运行了一个捆绑安装,但每次我尝试创建一个pdf时仍会出现此错误.请帮忙

fl0*_*00r 6

你应该在这里阅读安装自述文件:

https://github.com/jdpace/PDFKit

所以你需要安装wkhtmltopdf manualy:

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

或者像这样

gem install wkhtmltopdf-binary
Run Code Online (Sandbox Code Playgroud)

PS

校验 which wkhtmltopdf

并创建新文件config/initializers/pdfkit.rb

PDFKit.configure do |config|
  config.wkhtmltopdf = 'PATH/TO/wkhtmltopdf'
end
Run Code Online (Sandbox Code Playgroud)