加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 由于“wkhtmltopdf”,PDFKIT显然无法正常工作

发布时间:2020-12-17 03:34:21 所属栏目:百科 来源:网络整理
导读:我在从html页面生成PDF时遇到问题. 我正在使用PDFkit.在安装它的过程中,我注意到我需要wkhtmltopdf.所以我也安装了它.我做了PDFkit的文档所说的所有内容..现在我在尝试加载PDF时遇到此错误. 这是错误: command failed: "/usr/local/bin/wkhtmltopdf" "--mar
我在从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" "-" "-"

知道这可能是什么?

谢谢

解决方法

我的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可执行文件的路径.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读