Locally It works like magic but when I try to generate the PDF on the server it trows:
RuntimeError (Failed to execute:
"/path/to/my/project/vendor/bundle/ruby/1.9.1/bin/wkhtmltopdf" -q - -
Error: Broken pipe):
Here's what's 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'