Rails アプリで PDFkit gem を使用しようとしています。しかし、wkhtmltopdf をロードできません。私は最初にこれを試しました:
$ brew install wkhtmltopdf
そして、これを得ました:
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/qt- 4.8.0-bottle.tar.gz
######################################################################## 100.0%
Error: SHA1 mismatch
Expected: d03b56811d2cac933b6103bd4c8ac636dea3b877
Got: 2bfe00c5112b0d2a680cd01144701f8937846096
Archive: /Users/burtondav/Library/Caches/Homebrew/qt-4.8.0.bottle.tar.gz
(To retry an incomplete download, remove the file above.)
そこで、wkhtmltopdf.app をダウンロードして、Applications フォルダーに入れました。次に、config/initializers フォルダーに pdfkit.rb を作成しました。このコードで:
PDFKit.configure do |config|
config.wkhtmltopdf = 'C:\Applications\wkhtmltopdf.app' #Path to your wkhtmltppdf installation directory
config.root_url = "http://localhost" # Use only if your external hostname is unavailable on the server.
end
今、次のエラーが表示されます。
No wkhtmltopdf executable found at C:\Applications\wkhtmltopdf.app
助けてくれてありがとう!!
アップデート
PDFkit は Heroku で動作しますか?
更新2
これをコマンドラインで実行したところ、うまくいきました!だから、私はそれが私のMacにあることを知っています。
/Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf "http://www.google.com" google.pdf
更新3
アプリケーション内の同じ名前のフォルダーに入れて、これを試しました:
config.wkhtmltopdf = '/Applications/wkhtmltopdf ' #Path to your wkhtmltppdf installation directory
しかし、それもうまくいきませんでした。