I have
bundle exec rails -v
Rails 2.3.11
which wkhtmltopdf
/usr/bin/wkhtmltopdf
pdfkit (0.5.0)
The site is served with nginx + passenger
Loading a simple page generates:
/!\ FAILSAFE /!\ Tue Jun 07 00:55:33 -0400 2011 Status: 500 Internal Server Error command failed: "/usr/bin/wkhtmltopdf" "--margin-right" "0.5in" "--page-size" "Letter" "--margin-top" "0.5in" "--margin-bottom" "0.5in" "--print-media-type" "--orientation" "Landscape" "--margin-left" "0.5in" "--quiet" "-" "-" /usr/lib/ruby/gems/1.8/gems/pdfkit-0.5.0/lib/pdfkit/pdfkit.rb:71:in `to_pdf' /usr/lib/ruby/gems/1.8/gems/pdfkit-0.5.0/lib/pdfkit/middleware.rb:19:in `call' /usr/lib/ruby/g开发者_如何学JAVAems/1.8/gems/actionpack-2.3.11/lib/action_controller/string_coercion.rb:25:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.2/lib/rack/head.rb:9:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.2/lib/rack/methodoverride.rb:24:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.11/lib/action_controller/params_parser.rb:15:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.11/lib/action_controller/session/abstract_store.rb:177:in `call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/query_cache.rb:29:in `call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/query_cache.rb:9:in `cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/query_cache.rb:28:in `call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.11/lib/action_controller/failsafe.rb:26:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.2/lib/rack/lock.rb:11:in `call'
This works perfectly with my development server. Any troubleshooting options greatly appreciated.
I believe that this problem is with your path in the initialization of PDFkit. For example:
html_file = File.new('html/your-file.html')
kit = PDFKit.new(html_file, :page_size => 'Letter', :header_html => "**html/template/header.html**", :footer_html => "**html/template/footer.html**")
This is a relative path, and the initialization, locally, is ok. Maybe you should change your path to work correctly with nginx.
精彩评论