0

我有

捆绑 exec rails -v

导轨 2.3.11

哪个 wkhtmltopdf

/usr/bin/wkhtmltopdf

pdfkit (0.5.0)

该站点由 nginx + 乘客服务

加载一个简单的页面会生成:

/!\ FAILSAFE /!\ 2011 年 6 月 7 日星期二 00:55:33 -0400
  状态:500 内部服务器错误
  命令失败:“/usr/bin/wkhtmltopdf”“--margin-right”“0.5in”“--page-size”“字母”“--margin-top”“0.5in”“--margin-bottom” “0.5in” “--print-media-type” “--orientation” “横向” “--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/gems/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'

这与我的开发服务器完美配合。非常感谢任何故障排除选项。

4

1 回答 1

1

我相信这个问题与您在PDFkit初始化中的路径有关。例如:

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**")

这是一个相对路径,本地初始化是可以的。也许您应该更改路径以正确使用 nginx。

于 2012-03-09T17:31:32.967 回答