我已經使用RVM(必須手動複製wkhtmltopdf二進制文件)在我的Rails 3應用程序中設置PDFKit。當我嘗試渲染頁面的PDF版本,我得到這個錯誤:Rails 3 - 使用PDFKit創建PDF文檔時wkhtmltopdf命令失敗
RuntimeError in AgenciesController#show command failed: ["lib/wkhtmltopdf/wkhtmltopdf", "--disable-smart-shrinking", "--page-size", "Letter", "--margin-top", "0.75in", "--margin-right", "0.75in", "--margin-bottom", "0.75in", "--margin-left", "0.75in", "--encoding", "UTF-8", "--quiet", "\n.......\n", "-"]
以下是我的applicaition.rb:
config.middleware.use "PDFKit::Middleware" PDFKit.configure do |config| config.wkhtmltopdf = 'lib/wkhtmltopdf/wkhtmltopdf' end
爲什麼發生這種情況的想法?我該如何解決它?
在控制檯中,我注意到了這個消息:
(sometimes it will work just to ignore this error with --ignore-load-errors)
在哪裏調用該開關? wkhtmltopdf似乎在命令行上工作正常,我可以做類似「./wkhtmltopdf http://www.google.com google.pdf」並生成PDF。
感謝您的幫助,
彼得
我試着config.wkhtmltopdf絕對路徑,重新啓動服務器,但得到了同樣的錯誤。 – futureshocked 2010-08-12 13:38:46
你有沒有設法解決它?我在'my_app_path/lib/wkhtmltopdf'上存儲了可執行文件就像你說的那樣從終端工作。但在生產模式下運行Webrick服務器時不起作用。任何幫助,將不勝感激。謝謝 – TheMouseMan 2014-01-13 11:41:31
不,我放棄了這種方法,因爲它不適合我正在嘗試做的事情,而是去了Prawn(https://github.com/prawnpdf/prawn)。 – futureshocked 2014-01-14 02:00:42