【问题标题】:PDFKIT apparently not working because of "wkhtmltopdf"由于“wkhtmltopdf”,PDFKIT 显然无法正常工作
【发布时间】:2011-01-28 23:33:42
【问题描述】:

我无法从 html 页面生成 PDF。

我正在使用 PDFkit。在安装它的过程中,我注意到我需要 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" "-" "-"

知道这可能是什么吗?

谢谢

【问题讨论】:

    标签: ruby-on-rails ruby pdfkit


    【解决方案1】:

    我的 rails 应用程序中有以下配置。我在 irb 中测试过,效果很好。

    PDFKit.configure do |config|
      config.wkhtmltopdf = `which wkhtmltopdf`.to_s.strip
      config.default_options = {
        :encoding=>"UTF-8",
        :page_size=>"A4",
        :margin_top=>"0.25in",
        :margin_right=>"1in",
        :margin_bottom=>"0.25in",
        :margin_left=>"1in",
        :disable_smart_shrinking=>false
        }
    end
    

    需要设置wkhtmlpdf可执行文件的路径。

    【讨论】:

    • 我在使用 rias 3.0.3 ruby​​ 版本 1.8.7-p352 之前它工作正常,但现在它向我显示与你相同的错误,但你的解决方案没有帮助
    【解决方案2】:

    我实际上是通过删除 PDFKit 和 wkhtmltopdf 让它工作的。并按照这里提到的一步一步进行:

    https://github.com/jdpace/PDFKit/

    (确保您手动安装 wkhtmltopdf)

    谢谢

    【讨论】:

      猜你喜欢
      • 2012-03-22
      • 2019-11-03
      • 2018-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多