Search code examples
ruby-on-railswkhtmltopdfpdfkit

PDFKit::NoExecutableError in EmployeesController#to_pdf


I was using PdfKit for generating pdf from my Html template till now. But suddenly it has started giving Error

The error message is given below

No wkhtmltopdf executable found at /usr/local/rvm/gems/ruby-2.3.0/bin/wkhtmltopdf >> Please install wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF

I have used

html = render_to_string(:action => "Pdf_template/Pdf.html.erb", :layout => false)

kit = PDFKit.new(html)

for generating PDF

I have tried to resolve it by installing gem wkhtmltopdf but it didn't helped the problem is wkhtmltopdf executable is present in my production and and my local environment but this error is occuring only in production not in my local environment

Thank you in advance


Solution

  • Please cross verify the install path for wkhtmltopdf, i am pretty confident its issue of path, below is the script where you have to add correct path of wkhtmltopdf

    config/initializers/wkhtmltopdf.rb

    PDFKit.configure do |config| 
      config.wkhtmltopdf = 'PATH/TO/wkhtmltopdf' 
    end