【发布时间】:2012-03-22 22:55:29
【问题描述】:
我无法从 html 页面生成 PDF。
我正在使用 PDFkit。我还按照安装说明安装了 wkhtmltopdf。在 'usr/local/bin/' 中现在有一个名为 'wkhtmltopdf' 的文件
当我使用 PDFkit 运行 pdf 时,它现在给出一个错误:
command failed: "/usr/local/bin/wkhtmltopdf" "--margin-right" "0.75in" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-bottom" "0.75in" "--encoding" "UTF-8" "--margin-left" "0.75in" "--quiet" "-" "-"
另外,当我尝试直接生成 PDF 时,它会报错:
wkhtmltopdf --page-size A4--quiet http://localhost/invoices/22 -
'/usr/local/bin/wkhtmltopdf: cannot execute binary file'
知道这可能是什么吗? 这是 PDFkit 配置文件的外观:
PDFKit.configure do |config|
config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf'
end
【问题讨论】:
-
当我遇到类似的错误是因为我正在执行的帐户没有对 wkhtmltopdf 的执行权限。我最终在上面做了一个
chmod。 -
我检查了权限,但它拥有所有用户的所有权限。
-
似乎有些安装问题。您正在使用哪个版本的 WKHTMLTOPDF 以及在哪个操作系统中?
-
我在 mac os x lion 上遇到了类似的问题。
标签: ruby-on-rails-3 wkhtmltopdf