Prawn: The Pure Ruby PDF Generation Library

By Peter Cooper

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.