7

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 ?

geca
  • 2,711
  • 2
  • 17
  • 26
KKB
  • 558
  • 4
  • 18

3 Answers3

17

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.

Vrushali Pawar
  • 3,753
  • 1
  • 13
  • 22
5

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.

joshweir
  • 5,427
  • 3
  • 39
  • 59
5

config/initializers/wicked_pdf.rb

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

WickedPdf.config = { exe_path: path }
Thaha kp
  • 3,689
  • 1
  • 26
  • 25
  • 3
    Although your code snippet might solve the issue, you should describe what’s the purpose of your code (how it solves the problem). Furthermore, you might want to check https://stackoverflow.com/help/how-to-answer – Ahmad F Mar 07 '18 at 07:12