1

I am trying to use pdf generator in my rails 2.3app. It is working fine in my local machine and pdf is generating. In my production server (nginix) it is not working and shows the error:

"wkhtmltopdf RuntimeError (Location of wkhtmltopdf unknown)"

In the config/initializers/wicked_pdf.rb.example file I have mentioned the path to the binary exe file as:

WickedPdf.config = {
   :wkhtmltopdf => '/opt/wkhtmltopdf-amd64',
   :layout => 'pdf.html'
   :header => {:html => {:template=> 'layouts/pdf_header.html'}}
} 

And in the opt folder there is wkhtmltopdf-amd64 binary exe file.

simonmorley
  • 2,810
  • 4
  • 30
  • 61
rubyist
  • 3,074
  • 8
  • 37
  • 69

2 Answers2

1

:wkhtmltopdf => '/opt/wkhtmltopdf-amd64',

This is your system opt folder, check whether this folder has permission to execute the binary.

Alternatively change the location of wkhtmltopdf into your rails application by extracting it to /path/to/rails_app/bin

and then change your initializer to :wkhtmltopdf => Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s

Matt
  • 13,948
  • 6
  • 44
  • 68
Rajarshi Das
  • 11,778
  • 6
  • 46
  • 74
0

can we replace the path with installed gem at gemset? At terminal just check 'which wkhtmltopdf' is installed in our app gemset path.Then replace the path your wkhtmltopdf initializer with that.

Jaswinder
  • 1,455
  • 14
  • 27