Locally This works like magic, but when I try to create a PDF on the server, it throws:
RuntimeError (Failed to execute: "/path/to/my/project/vendor/bundle/ruby/1.9.1/bin/wkhtmltopdf" -q - - Error: Broken pipe):
Here that on my_controller .
format.pdf do pdf = render_to_string( :pdf => "invoice", :template => "my_controller/my_view.pdf.erb", :layout=>"pdf.html.erb" ) save_path = Rails.root.join('pdfs','invoice.pdf') File.open(save_path, 'wb') do |file| file << pdf end send_file(save_path) end
And in my gemfile
gem 'wicked_pdf' gem 'wkhtmltopdf-binary'
source share