Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails PDF generating alternative to Prawn

I've been using Prawn to generate simple invoice PDFs. I now have the need to create a more complicated PDF document and Prawn is coming up short. I need to copy an existing layout precisely so converting from HTML (a la Princely) is not an option.

Can anyone recommend a good alternative, or any alternative for that matter?

like image 424
Peter Duijnstee Avatar asked Dec 08 '10 14:12

Peter Duijnstee


3 Answers

iText is probably the best answer that developers of any language have for generating PDFs. It isn't a perfect answer for you because it is a Java library. However, you may find it worth your time to stub out a java program that takes the data and works with iText to output a PDF.

You can also interface with iText through Groovy.

http://itextpdf.com/

like image 141
Mike Avatar answered Oct 14 '22 18:10

Mike


iText is very useful. There's a Ruby wrapper around it called pdf-stamper, which allows you to fill text in fields — which would be useful for an invoice.

I forked it and added a few features (checkboxes, drawing circles, etc.): https://github.com/paulschreiber/pdf-stamper

like image 2
Paul Schreiber Avatar answered Oct 14 '22 19:10

Paul Schreiber


iText is rather useful. You can use it to stamp text in known places on an input PDF, or to fill in form fields in an input PDF. The current version of iText is AGPL'd, but prior versions are LGPL'd. To use this from Ruby, you would either need to use jrb or JRuby.

pdftk is a command-line tool wrapping (an older version of) iText. Magically, you do not need a JRE installed to use pdftk. You can shell out to pdftk from within any Ruby.

like image 1
yfeldblum Avatar answered Oct 14 '22 18:10

yfeldblum