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'
Fixed removing system installed wkhtmltopdf
and using the binary of wkhtmltopdf:
apt-get remove wkhtmltopdf --purge
sudo curl -C - -O http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
sudo tar -xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
ln -s wkhtmltopdf-amd64 wkhtmltopdf
WickedPdf.config = {
:exe_path => "/usr/local/bin/wkhtmltopdf"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With