application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require 'pdfkit'
Bundler.require(:default, Rails.env)
module PdfTest
class Application < Rails::Application
config.middleware.use PDFKit::Middleware, :print_media_type => true
end
end
config/initializers/pdfkit.rb
PDFKit.configure do |config|
config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf'
end
controller
respond_to :html, :pdf
然后写了一个 test.html.erb 页面 后缀加上".pdf" 报如下错误 请指教一二,谢谢
那这个能成功么?
echo foo | 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 - - > a.pdf
#13 楼 @liker 把 turbolinks 去掉应该就好了 http://blog.steveklabnik.com/posts/2013-06-25-removing-turbolinks-from-rails-4