English 中文(简体)
PDFKit (wkhtmltopdf) B. 管道、SOSX和铁路 3
原标题:PDFKit (wkhtmltopdf) Broken Pipe, OS X and Rails 3

I m using PDFKit (which uses wkhtmltopdf) in an attempt to render a view as pdf within a Rails 3 app.

PDFKit renders with Errno::EPIPE (Broken pipe) pointing to send_data(kit.to_pdf, :filename => "generated.pdf", :type => application/pdf ) in my controller show action:

# Controller
def show
  respond_to do |format|
    format.html { render }
    format.pdf do
      html = render_to_string(:layout => false , :action => "show.html.haml")
      kit = PDFKit.new(html)
      send_data(kit.to_pdf, :filename => "invoice.pdf", :type =>  application/pdf )
      return # to avoid double render call
    end
  end
end

# Gemfile
...
gem  pdfkit 
gem  wkhtmltopdf 
...

我知道Wkhtmltopdf不是这一错误的源头,即wkhtmltopdf public/404.html tmp/404.pdf,从Rails.root起,按预期使用。

http://www.jonathanspies.com/posts/11-Simple-PDFkit-example-in-Rails-3” 在使用中间器后,未能以同样的方式使用中间器。

# config/application.rb
require  pdfkit 
config.middleware.use PDFKit::Middleware

在用新的铁路3号 app车进行审判后,我发现以下错误:

command failed: "~/.rvm/gems/ree-1.8.7-2011.01@blog/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-right" "0.75in" "--margin-top" "0.75in" "--margin-bottom" "0.75in" "--encoding" "UTF-8" "--margin-left" "0.75in" "--quiet" "-" "-"

显示采用人工操作的指挥和使用情况检查,看一看——平静的选择,很容易看到它本应放弃——

更改/lib/pdfkit/pdfkit.rb:35 对以下各项工作的影响和所有工作(也使用中层知识)。

args <<  --quit 

因此,我再次在撰写问题以获得帮助(途径包括细节)时解决了我的问题。 我提交了“,其中纠正了拼写的错误(al误了无知)。 没有人会想到,我走过任何道路。

最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 关于将静态论点改为空谈。

这一改动只有在你使用使用非常旧的Wkhtmltopdf binary时才会有效。

With the wkhtmltopdf gem

10:32:15 wkhtml >     wkhtmltopdf --version
wkhtmltopdf 0.8.3 using wkhtmltopdf patched qt
Copyright (C) 2008,2009 Jakob Truelsen,
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jakob Truelsen
Patches by Mário Silva and Emmanuel Bouthenot

10:32:16 wkhtml >     wkhtmltopdf --help | grep quit
  -q, --quit                      Be less verbose.
10:32:16 wkhtml >     wkhtmltopdf --help | grep quite
10:32:19 wkhtml > 

安装了最新的双筒一

10:33:40 tmp > wkhtmltopdf --version
Name:
  wkhtmltopdf 0.9.9

License:
  Copyright (C) 2008,2009 Wkhtmltopdf Authors.



  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
  This is free software: you are free to change and redistribute it. There is NO
  WARRANTY, to the extent permitted by law.

Authors:
  Written by Jakob Truelsen. Patches by Mário Silva, Benoit Garret and Emmanuel
  Bouthenot.

10:33:50 tmp > wkhtmltopdf --help | grep quit
10:34:02 tmp > wkhtmltopdf --help | grep quiet
  -q, --quiet                         Be less verbose
10:34:07 tmp > 

旧的双手里存在混杂的错误。 我建议你把 w子包裹放在一刀子上,如果你把 w子html到pdf g子上,则以 initial子或一些东西为基础。

我也接受一项拉皮书,使pdfkit知道Wkthtmltopdf的版本,它正在反对这一论点,并有条件地加以改变。

问题回答

Change /lib/pdfkit/pdfkit.rb:35 to the following and everything works as expected (with middleware too).

args <<  --quit 




相关问题
Remove ActiveRecord in Rails 3

Now that Rails 3 beta is out, I thought I d have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB ...

When will you upgrade your app to Rails 3? [closed]

Now that the Rails 3 beta is here, let s take a little straw poll. Please tell us briefly what your application does and when you will upgrade it to Rails 3. Or, if you re not planning on upgrading ...

Bundler isn t loading gems

I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I ...

bypass attr_accessible/protected in rails

I have a model that, when it instantiates an object, also creates another object with the same user id. class Foo > ActiveRecord::Base after_create: create_bar private def create_bar Bar....

concat two fields activerecord

I m so used to oracle where you can simply concat(field1, , field2) but if I m using activerecord to find the field1 and field2, and I need a space in between, how do I accomplish this? Cheers ...

热门标签