fut*_*ked 5 ruby-on-rails pdfkit wkhtmltopdf
我在Rails 3应用程序中使用RVM设置了PDFKit(必须手动复制wkhtmltopdf二进制文件).当我尝试渲染页面的PDF版本时,我收到此错误:
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", "-"]
以下是我的应用程序.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.
谢谢你的帮助,
彼得
从源代码来看,您可以在pdfkit上设置选项.我认为以下内容可行:
PDFKit.configure do |config|
config.default_options[:ignore_load_errors] = true
end
Run Code Online (Sandbox Code Playgroud)
(虽然我没试过)