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.