PDFKit 不会在 Ubuntu on Rails 上渲染

发布于 2024-11-13 12:13:28 字数 1902 浏览 7 评论 0原文

我有

捆绑包 execrails -v

Rails 2.3.11

其中 wkhtmltopdf

/usr/bin/wkhtmltopdf

pdfkit (0.5.0)

该网站由 nginx +乘客 加载

一个简单的页面生成:

/!\ 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/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'

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

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/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'

This works perfectly with my development server. Any troubleshooting options greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最单纯的乌龟 2024-11-20 12:13:28

我相信这个问题与您在 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。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文