【发布时间】:2013-02-18 22:34:39
【问题描述】:
我正在尝试在 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
我将它放入 Applications 中的同名文件夹并尝试了这个:
config.wkhtmltopdf = '/Applications/wkhtmltopdf ' #Path to your wkhtmltppdf installation directory
但是,那也没用。
【问题讨论】:
-
是的,PDFkit 可以在 heroku 上运行。
-
如何在我的 Rails 应用程序中配置它以在 Heroku 上运行?
-
如果您得到其他帮助,请添加您自己的答案:)