Why does PDFKit/wkhtmltopdf hang but renders PDF as expected when Rails app is killed?

后端 未结 7 1472
無奈伤痛
無奈伤痛 2020-12-04 12:18

Background

After reading around it seemed to me that Prawn is out and wkhtmltopdf is in. It also seems like the PDFKit and wicked_pdf gems for Rails are the new co

7条回答
  •  無奈伤痛
    2020-12-04 13:05

    Exact same symptoms but using WickedPdf currently. At this point, I believe the issue lies with wkhtmltopdf as well.

    Unfortunately, neither of the recommendations I've been able to find in Stack/Google worked for me. Instead, I needed to combine several suggestions, including some found in this post.

    Solution was:

    1. brew uninstall wkhtmltopdf
    2. find and delete any copies of wkhtmltopdf in /usr/bin
    3. comment WickedPdf.config line in config/initializers
    4. add config.threadsafe! to development.rb
    5. remove middleware and allow 'show' action of main controller to handle pdf requests (may not be necessary)
    6. add wkhtmltopdf-binary to gemfile
    7. bundle
    8. restart server
    9. You may also need to add Mime::Type.register_alias "application/pdf", :pdf to config/initializers/mime_types.rb (for me, this causes 'warning: already initialized constant PDF')

    My set-up was: Mac OSX Mountain Lion with Rails 3.2.1, Webrick, Postgres and wkhtmltopdf-binary (0.9.9.1).

提交回复
热议问题