Prawn: The Pure Ruby PDF Generation Library
Prawn is a new pure Ruby PDF generation library developed primarily by Gregory Brown.
Back in March, Gregory tried to raise $13000 so he could spend six months working on Ruby-related open source projects. He eventually raised $5525 from the community (plus $5000 from Ruby Central and $500 from Mountain West RubyConf) and has spent the last few months working on Prawn.
Prawn can be installed from a pull from GitHub or, for those of us who are less adventurous, with a gem install prawn. Once installed, you can give it a quick test run:
require 'prawn' Prawn::Document.generate("test.pdf") do font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf" text "this is a test " * 100 end
Prawn comes with 11 typefaces, including Helvetica, Courier, DejaVuSans, Times, and everyone's favorite - Comic Sans. It already supports image embedding, table drawing, and content positioning, but a lot more is yet to come. Prawn is now ripe for more community involvement and support, so if you want to help (Gregory's looking for a logo!) the prawn-ruby Google Group is a great place to start.
Update: Gregory has created the "Prawn Gallery" on GitHub as a place for people to show off their Prawn-created PDFs.
August 4, 2008 at 4:08 pm
For crying out loud, it is either this:
Prawn can be pulled using git
or
Prawn can be pulled from Github
Understand?
You can't "pull" from "Git". Git is a program. You might use it to pull something, although unless you have it already you'd probably clone first, THEN pull. Saying "pull from Git" is like saying "download from Safari".
Secondly, Github is NOT git. It is a great website (although beginning to suffer reliability problems) but it is not git itself. Can you please stop confusing the two? It's like people who think IE is the internet.
That said, prawn looks like a great tool and I look forward to trying it out.
August 4, 2008 at 4:20 pm
Can you please stop confusing the two?
It was a one-off typo. Thanks for pointing it out, but a patronizing diatribe wasn't necessary.
August 4, 2008 at 4:48 pm
For me key question: does prawn support utf-8?
August 4, 2008 at 4:54 pm
Yes. Check out the main Prawn link above. It's the second section on the page.
August 4, 2008 at 5:25 pm
Hi Peter,
Thanks so much for posting this. It's worth mentioning that Mountain West RubyConf also donated $500, not listed on the Pledgie.
-greg
August 4, 2008 at 5:34 pm
hk - every little outburst like that supports ***'s claim.
August 4, 2008 at 5:59 pm
Gregory: Didn't know that - added - thanks!
August 5, 2008 at 1:43 am
Hey Peter--
Hope you don't mind the plug, but it seemed relevant. Just in case you didn't know, there also exists an unofficial but worthy rails sister plugin-- prawnto. It lets you create compiled pdf views leveraging the prawn library.
http://cracklabs.com/prawnto
http://github.com/thorny-sun/prawnto.git
hope it helps the rails folks out there... enjoy!
-thorny_sun
August 5, 2008 at 1:45 am
oops-- that last github link was meant to be:
http://github.com/thorny-sun/prawnto
August 5, 2008 at 1:49 pm
Insanity Prawn Boy -- exactly what I think of every time this library gets mentioned :).
August 5, 2008 at 2:56 pm
Oh man... I've never seen that cartoon before. Disturbing and wonderful all at the same time.
August 5, 2008 at 4:23 pm
hk - your role as "language police" is not at all becoming, especially since this is a free website that Mr. Cooper is good enough to provide for us and with which he does a remarkable job.
I installed Prawn PDF library last night. It works as advertised on Leopard. Nice work and congratulation to Gregory Brown.
August 5, 2008 at 4:26 pm
I'm testing the Rghost is cool to use the ttf fonts inside of pdf
August 6, 2008 at 2:39 am
You can checkout from subversion, so why can't you pull from git? Discrimination?
August 6, 2008 at 3:02 am
I cant image why one would want a rails plugin for prawn. I really dislike all these little small rails plugins. just use the original library!!!!! on a site note, i hate installing from github with name-gem.git then require gem.git. what a mess. All these ruby innovations are great, but not the huge mess its creating.
August 6, 2008 at 3:58 am
Captain Semantics: To be fair to hk's original point, if someone were to be as technically pedantic as he was then "checkout from subversion" should really be "checkout from [a/this/their/our] Subversion repository." Of course, we're not that pedantic, so we'll all let it slide ;-)
August 6, 2008 at 4:15 pm
This looks great, thanks for your work, Gregory!
August 6, 2008 at 5:46 pm
@carlity,
Prawnto just makes templates a little easier. Not exactly something that I feel I need, but useful for those who like that sort of thing.
Also, I agree, the name-gem thing on Git is a little weird. Very useful for *unofficial* gems but I can't see hosting a project that way officially. So Prawn is not using that feature, it has a normal gem on RubyForge.
August 8, 2008 at 3:17 pm
Just one thing:
can I put in one line a text with 2 or more color like:
Name: My Name
?
regards
August 8, 2008 at 3:19 pm
ops
like:
| blue | Name: | \ blue | | green | My name | \ green |
August 9, 2008 at 5:44 am
What great timing; I was going to implement PDF generation this weekend. Thanks Gregory!
August 14, 2008 at 11:24 am
Any one actually know how to put this into a Rails app? Sorry if this is totally stupid of me, but I don't know if this code goes in the controller or the view or model or where... sorry. The docs don't appear to say either unless I've missed something...