Question

I'm finishing a PDF report implementation for my application, which works perfectly in development mode, but when uploading to Heroku, it doesn't work, and I get the following error:

2011-10-24T03:28:02+00:00 app[web.1]: RuntimeError (Failed to execute:
2011-10-24T03:28:02+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/bin/wkhtmltopdf --header-html 'file:///app/tmp/wicked_header_pdf_1_0.html' --footer-html 'file:///app/tmp/wicked_footer_pdf_1_0.html'     --orientation 'landscape' --page-size 'A4' --encoding 'UTF-8'   -q - - 
2011-10-24T03:28:02+00:00 app[web.1]: Error: PDF could not be generated!):
2011-10-24T03:28:02+00:00 app[web.1]:   app/controllers/gliders_controller.rb:244:in `block (2 levels) in report'
2011-10-24T03:28:02+00:00 app[web.1]:   app/controllers/gliders_controller.rb:228:in `report'

I've tried adding an initializer and manually uploading the wkhtmltopdf bin file to heroku following the example in this github repository, but I still can't get it to work.

I can't seem to grasp the exact reason why this wouldn't work in Heroku, could anyone give me a hand? Thanks in advance.

Was it helpful?

Solution

I got it to work. After a little searching, I found a github repo that implements a wicked_pdf initializer that works with Rails 3 and Heroku.

To make this work in your app:

  1. Copy the bin directory to the root of your application
  2. Copy the wickedpdf.rb into your config/initializers directory so that you get the same errors from heroku
  3. Copy the "config.after_initialize do" statement from development.rb so that your local binary is found in development.

OTHER TIPS

Heroku is a read-only filesystem and you're attempting to create a new file on that system. You cannot do this.

Using the wkhtmltopdf-binary gem will make wicked_pdf work in all environments. This takes away the need to manually install wkhtmltopdf on your local machine or on any production server.

gem install wkhtmltopdf-binary

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top