我在 Rails 应用程序中使用 gem 'pdfkit'。它在 Heroku 上运行良好,但在我的 iMac 上出现错误。
错误:
command failed: "/users/myname/sites/ndeavor2/bin/wkhtmltopdf-amd64"
应用程序 wkhtmltopdf-amd64 位于错误指示的文件夹中!
我的 application.rb 有:
config.middleware.use "PDFKit::Middleware", :print_media_type => true
我有一个名为 pdfkit.rb 的初始化程序
PDFKit.configure do |config|
config.wkhtmltopdf = Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s
end
谢谢您的帮助!
更新1
我下载了 wkhtmltopdf.app 并放置在与 amd64 版本相同的位置。
我将 pdfkit.rb 更改为:
PDFKit.configure do |config|
config.wkhtmltopdf = Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s if Rails.env.production?
config.wkhtmltopdf = Rails.root.join('bin', 'wkhtmltopdf.app').to_s if Rails.env.development?
end
我还将 wkhtmltopdf.app 的副本放入应用程序文件夹并尝试了以下操作:
config.wkhtmltopdf = '/applications/wkhtmltopdf.app' if Rails.env.development?
我收到此错误:
command failed: