0

I am trying to generate PDF reports with wicked_pdf gem. THe PDF generation works fine on my development environment, but it fails once it's deployed on Heroku

This is the error I am getting:

Failed to execute:
 /app/.bundle/gems/ruby/1.9.1/bin/wkhtmltopdf --header-font-name 'Century Gothic' --header-left 'My Test - Neuffen, Germany' --header-right '2012-02-05 15:50:57 -0800' --header-font-size 14 --header-line  --footer-center 'Generated by Biowatts - http://biowatts.org' --footer-font-name 'Century Gothic' --footer-font-size 13 --footer-line   --toc-font-name 'Century Gothic' --toc-disable-links  --toc-disable-back-links     --orientation 'Landscape' --no-background    -q - - 
Error: PDF could not be generated!
 .bundle/gems/ruby/1.9.1/gems/wicked_pdf-0.7.2/lib/wicked_pdf.rb:39:in `rescue in pdf_from_string'

Any idea how to address this issue?

20120207 - Additional attemps

When adding these to my gem file, I get a diffenret error:

group :production do
   gem "wkhtmltopdf-heroku", :git => 'git://github.com/camdez/wkhtmltopdf-heroku.git'  
end

The Error:

Location of wkhtmltopdf unknown
  .bundle/gems/ruby/1.9.1/gems/wicked_pdf-0.7.2/lib/wicked_pdf.rb:20:in `initialize' 
zabumba
  • 12,172
  • 16
  • 72
  • 129

1 Answers1

1

You need to package the wkhtmltopdf binary with your application as it's not normally present on the heroku stack.

It's basically a case of adding the binary to git, and then telling your code where the binary is.

More info here: http://blog.mattgornick.com/using-pdfkit-on-heroku

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
  • I will try this, but I was wondering whether it wasn't rather because it tries to write somewhere on the heroku stack when generating the PDF, see the first error message. My second attempt (20120207) with wkhtmltopdf-heroku does give "wkhtmltopdf unknown" which suggest that indeed it's looking for that binary, but I didn't get that before. – zabumba Feb 29 '12 at 20:48