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 ?
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.
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.
config/initializers/wicked_pdf.rb
path = `which wkhtmltopdf`.gsub(/\n/, "")
WickedPdf.config = { exe_path: path }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With