Reputation: 51
Locally It works without any error but when I try to generate the PDF on the server it throws:
RuntimeError (Failed to execute:
["/usr/local/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20180531-994-1x8fbfn.html", "/tmp/wicked_pdf_generated_file20180531-994-1vidmtk.pdf"]
Error: PDF could not be generated!
Command Error: /usr/bin/env: ruby: No such file or directory
Here's what's on my_controller.
pdf=WickedPdf.new.pdf_from_string(render_to_string('disc_bill',:layout=>false))
save_file = Rails.root.join("public","bill.pdf")
File.open(save_file, 'wb') do |file|
file << pdf
end
And in my Gemfile
gem 'wicked_pdf', '~> 1.1'
gem 'wkhtmltopdf-binary', '~> 0.12.3.1'
Upvotes: 0
Views: 1463
Reputation: 156
Looks like the wkhtmltopdf command is not in the PATH, you can fix this by changing the WickedPdf.config to
WickedPdf.config = {
exe_path: Rails.env.production? ? '/path/to/bin/wkhtmltopdf' : '/usr/local/bin/wkhtmltopdf'
}
Upvotes: 1
Reputation: 51
When I downgrade the version of wkhtmltopdf to 0.9.9 in the server worked for me
Upvotes: 0