Pdf export in rails
I need to export an HTML page with some charts in to a PDF开发者_如何学Python, what are some good gems to do this?
PDFKit http://railscasts.com/episodes/220-pdfkit and Prawn http://railscasts.com/episodes/153-pdfs-with-prawn.
My choice is PDFKit.
In deal with charts it can be a problem. Recommend to use graphic charts in this case. But maybe canvas is supported.
I use wicked_pdf to export the ouputted HTML of pages from Ruby on Rails as PDF. It works very well, and supports a ton of options.
I'm leaving this as a breadcrumb for anyone who comes across this question later...
I just tackled a project involving complex tables, graphs pulled from Google charts and looked at three options:
- prawn
- pdfkit
- wickedpdf
Prawn is brilliantly done but its the right choice for making a simple invoice not a complex set of data which needs to exist both in html from Ruby views and PDF.
pdfkit and wickedpdf are both pdf renderers from html templates and they use the same underlying engine. This is being done for an older Rails 2.3 app and I was able to get pdfkit to work in development mode but not in production under Passenger.
I was unable to get wickedpdf to work at all in Rails 2.3.
Overall both of these look good but I had better luck with pdfkit for my application. I would have spent at least a full week using Prawn and I got pdfkit working in less than a few hours.
精彩评论