本地它像魔术一样工作,但是当我尝试在服务器上生成 PDF 时,它会抛出:
RuntimeError (Failed to execute:
"/path/to/my/project/vendor/bundle/ruby/1.9.1/bin/wkhtmltopdf" -q - -
Error: Broken pipe):
这是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
在我的Gemfile
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'