RahulOnRails
RahulOnRails

Reputation: 6542

ROR + PdfKit + No such file or directory -"C:\\Program\ Files\\wkhtmltopdf\\wkhtmltopdf.exe"

In my project, I have used PDFKIT at windows platform. Initially it worked fine but now it is giving some strange error message.

No such file or directory - "C:\Program\ Files\wkhtmltopdf\wkhtmltopdf.exe" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--quiet" "-" "-"

I am not getting the way to resolve it and here is the ruby code.

kit = PDFKit.new(html)
send_data(kit.to_pdf, :filename => "#{file_name}.pdf", :type =>'application/pdf')

File : app/config/initializers/pdfkit.rb

PDFKit.configure do |config|
  config.wkhtmltopdf = 'C:\Program Files\wkhtmltopdf\wkhtmltopdf.exe'
  # config.default_options = {
  #   :page_size => 'Legal',
  #   :print_media_type => true
  # }
  # config.root_url = "http://localhost" # Use only if your external hostname is unavailable on the server.
end

Thanks in advance..

Upvotes: 1

Views: 1129

Answers (1)

Chris Hunt
Chris Hunt

Reputation: 4030

When this occurred on my system I resolved it by moving wkhtmltopdf to a directory whose path did not include a space.

Upvotes: 1

Related Questions