Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get wicked_pdf to work on heroku ? (but it works locally)

Following the guide on https://github.com/jordan-brough/heroku-pdf I managed to have wicked_pdf working locally and creating PDF as expected. However once I push to heroku, the app crashes after a while everytime I call the pdf

The logs gives me this:

2011-05-19T06:36:56+00:00 app[web.1]: Started GET "/authors/cash_payment_receipt/4dd4aff0a2d5a5000100000c.pdf" for XXX.XXX.XXX.XXX at Wed May 18 23:36:56 -0700 2011
2011-05-19T06:36:56+00:00 heroku[router]: Error H13 (Connection closed without response) -> GET xxx.xxxx.com/authors/cash_payment_receipt/4dd4aff0a2d5a5000100000c.pdf dyno=web.1 queue=0 wait=0ms service=0ms bytes=0
2011-05-19T06:36:56+00:00 app[web.1]: !! Unexpected error while processing request: PDF could not be generated!
2011-05-19T06:36:56+00:00 app[web.1]: /app/.bundle/gems/ruby/1.8/gems/wkhtmltopdf-0.1.2/bin/wkhtmltopdf_linux_386: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

I added the wkhtmltopdf bin to my rails-root/bin directory, checked the rights, and it's all ok. I first tried the 0.10rc2 and moved back down to 0.9.9 but it all gives the same results.

I can't find anything on google related to my error. I don't see what I am doing wrong.

The env is: - rails 3.0.7 - ruby 1.8.7

Thanks,

Ale

like image 206
Alex Avatar asked May 19 '11 06:05

Alex


3 Answers

I recently created a GEM for the wkhtmltopdf binaries to work on heroku without you having to install any binaries in your own repository. It also comes packed with the OSX ( darwin ) binary for development. It worked with PDFKit and probably should work with WickedPDF as well

https://github.com/bradphelan/wkhtmltopdf-heroku

or in your Gemfile as

gem "wkhtmltopdf-heroku"
like image 99
bradgonesurfing Avatar answered Oct 22 '22 14:10

bradgonesurfing


this github project was immensely helpful for me, I have it running in rails 3 projects thanks to this

like image 45
John Beynon Avatar answered Oct 22 '22 14:10

John Beynon


I was able to follow the steps described here https://github.com/jordan-brough/heroku-pdf to make my own copy of the project and it worked fine locally and on heroku.

I then updated the application to work with rails 3.0.9. It is running on heroku http://heroku-pdf-3.heroku.com/. You can grab my code from here for this project.

like image 4
tollbooth Avatar answered Oct 22 '22 13:10

tollbooth