I've already checked the path of wkhtmltopdf by using: which wkhtmltopdf I get this error in production.log RuntimeError (command failed: "/root/.rbenv/shims/wkhtmltopdf" "-encoding" "UTF-8" "-page-size" "A4" "-margin-top" "0.25in" "-margin-right" "0.25in" "-margin-bottom" "0.25in" "-margin-left" "0.25in" "-quiet" "-" "/root/app/bidimal/demo1.pdf"):
Part of my app involves generating pdf's from html web pages. So far everything is up and running smoothly except for one issue.
#Rails pdfkit pdf#
I can see the pdf file correctly generated, but if I try the same thing on action controller, in this way: kit = PDFKit.new("ciao") Rails - PDFkit not working in production Ask Question 1 Im working on deploying my rails application on an Ubuntu server with Apache2 and Passenger. If i run those commands in the my app console (RAILS_ENV=production rails c): kit = PDFKit.new(html, :page_size => 'Letter') I have a problem generating PDF file with pdf_kit gem. Prawn gives you more control over output but has a steeper learning curve, while PDFKit lets you use what you already know (HTML) to generate PDFs from standard Rails view and style code. I use rvm I added PDFkit to my gemfile and the. There are many ways to generate PDFs in Ruby and Rails, but we're going to focus on two: Prawn and PDFKit. It is a rails 3 app, 1.9.2 running on snow leopard. I was wondering if anyone else has experienced similar problems or has any clues as to what is going wrong. 我在nginx+passenger下,这个问题在任何nginx设置(比如可用的进程等等)下都可能有某种关联?谢谢您。 I was following along with Ryan Bates' really great railscast on PDFkit when I ran into a few problems installing wkhtmltopdf ( I also posted about my problem in the episode comments). 所以我认为这是正确的。顺便说一下,我在config/initializers中有这个/pdfkit.rb版 nfigure do |config|Ĭonfig.wkhtmltopdf = '/root/.rbenv/shims/wkhtmltopdf'Ĭfault_options = true You can use your controller to render the body of.
#Rails pdfkit how to#
我已经使用以下命令检查了wkhtmltopf的路径: which wkhtmltopdf How to use it from your Rails application You can have PDFKit render a website by simply calling PDFKit.
Register PDF as a mime-type in environment.rb: Mime::Type.register 'application/pdf', :pdf.Disable the PDFKit middleware so that your controller handles the generation of the PDF. 我犯了这个错误生产日志 RuntimeError (command failed: "/root/.rbenv/shims/wkhtmltopdf" "-encoding" "UTF-8" "-page-size" "A4" "-margin-top" "0.25in" "-margin-right" "0.25in" "-margin-bottom" "0.25in" "-margin-left" "0.25in" "-quiet" "-" "/root/app/bidimal/demo1.pdf"):Īpp/controllers/winners_controller.rb:69:in `invoice' How to cache the PDF using Rails page caching and PDFKit. Kit.to_file('/root/app/bidimal/demo1.pdf')