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

ruby-on-rails – Rails PDFKit命令失败

发布时间:2020-12-16 22:11:28 所属栏目:百科 来源:网络整理
导读:我试图在rails 3应用程序中使用PDFKit作为中间件. 我可以使用wkhtmltopdf从命令行很好,但我的应用程序不断给我这个错误 command failed: "/Users/bobby/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-top" "0.75in" "--margin
我试图在rails 3应用程序中使用PDFKit作为中间件.

我可以使用wkhtmltopdf从命令行很好,但我的应用程序不断给我这个错误

command failed: "/Users/bobby/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--print-media-type" "--quiet" "-" "-"

如果我在终端中运行,那么它等待我的输入,所以我输入一些HTML,然后按Ctrl-d,它会吐出一些似乎是一些PDF …但是没有运气.

这是我有的:

application.rb中

require File.expand_path('../boot',__FILE__)

require 'rails/all'
require 'pdfkit'
Bundler.require(:default,Rails.env) if defined?(Bundler)

module Mpr
  class Application < Rails::Application

    YEARS_ARRAY =  (2006..2012).map {|y| [y,y]}.unshift(["Year",nil])
    MONTHS_ARRAY = (1..12).map{|m| [ Date::MONTHNAMES[m],m]}.unshift(["All months",nil])
    config.middleware.use "PDFKit::Middleware",:print_media_type => true
    PDFKit.configure do |config|
      config.wkhtmltopdf = '/Users/bobby/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf'
    end
  end
end

在我的控制器(第一行)

respond_to :html,:pdf

我想我已经经历过SO,Github和Google的所有线程,但没有运气.

任何人可以帮助还是指向正确的方向?

谢谢,P.

解决方法

有人解决了这个问题和 kindly posted their solution.

(编辑:李大同)

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

    推荐文章
      热点阅读