Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad wkhtmltopdf's path for wicked_pdf and wkhtmltopdf

I am using two Gems to convert HTML to PDF.

Using "https://github.com/mileszs/wicked_pdf"

gem 'wicked_pdf'
gem "wkhtmltopdf-binary"

/initializer/wicked_pdf.rb

WickedPdf.config = {
  exe_path =>  "xxxxxxxxxxxxxxxxxxx"
}

What path should I use for the exe_path ?

like image 454
KKB Avatar asked Jun 04 '15 13:06

KKB


3 Answers

which wkhtmltopdf

This will give you path of your wkhtmltopdf. You should copy this path and paste in your config/intializers/wicked_pdf.rb And then restart your server.

like image 55
Vrushali Pawar Avatar answered Nov 10 '22 09:11

Vrushali Pawar


Add this to config/initializers/wicked_pdf.rb ensuring your correct GEM_HOME is being referenced:

WickedPdf.config = {
  :exe_path => "#{ENV['GEM_HOME']}/bin/wkhtmltopdf"
}

This way you wont be hard coding any paths.

like image 40
joshweir Avatar answered Nov 10 '22 10:11

joshweir


config/initializers/wicked_pdf.rb

path = `which wkhtmltopdf`.gsub(/\n/, "")

WickedPdf.config = { exe_path: path }
like image 5
Thaha kp Avatar answered Nov 10 '22 10:11

Thaha kp