Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fast, Nimble PDF Writer for Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

= Prawn: Fast, Nimble PDF Generation For Ruby

Prawn is a PDF writing library for Ruby designed to be tiny, fast, and nimble,
just like the majestic sea creature.

Development on this library was initially made possible thanks to 
the many people who donated to the Ruby Mendicant project: 

The project is currently maintained by Gregory Brown, with lots of help from
Prawn's core developers and the community.

== Quick Start

Getting started with Prawn can be as simple as:

 require 'prawn'
 pdf =
 pdf.text("Prawn Rocks")

But prawn can do a lot more:

===Any page size you can think of'A0') you an _really_ big page.   => [11.32, 8.49],
                     :page_layout => :portrait) you a postage stamp.

{Learn more}[link:classes/Prawn/Document.html]

===Multiple Font Handling with UTF-8 Support

 pdf.text("Prawn Rocks")
 pdf.text("Prawn still rocks in a different font")

...allowing you to use any font you want.

{Learn more}[link:classes/Prawn/Font.html]

===Drawing graphics directly into the page

Simple shapes:

 pdf.stroke do
   pdf.circle_at [100,100], :radius => 25
   pdf.rectangle [300,300], 100, 200

(note, you need to stroke the path to put "ink" there)

{Learn more}[link:classes/Prawn/Graphics.html]

===Embedding JPEG and PNG Images Natively

Reading an image directly from a file:

 prawn_logo = "#{Prawn::BASEDIR}/data/images/prawn_logo.png"
 pdf.image prawn_logo, :at => [50,450], :width => 450

Or reading it from an IO stream:

 require "open-uri"
 pdf.image open("")

{Learn more}[link:classes/Prawn/Images.html]

===Measurement Conversion Tools for Your Sanity

Prawn deals exclusively in PDF points... which work out to about 2.83464567mm... 
don't try and do it in your head, instead, let Prawn help you:

 require "prawn/measurement_extensions"

 Prawn::Document.generate(:page_layout => :portrait, 
                     :left_margin =>,    # different
                     :right_margin =>,    # units
                     :top_margin =>,    # work
                     :bottom_margin => 0.01.m, # well 
                     :page_size => 'A4') do
   text "Prawn Rocks"

{Learn more}[link:classes/Prawn/Measurements.html]

===Document Security, Permissions, and Encryption

See examples/security/ for example code, such as this:

  require 'prawn/security'

  Prawn::Document.generate("hello_foo.pdf") do
    text "Hello, world!"
    encrypt_document :user_password => 'foo', :owner_password => 'bar',
      :permissions => { :print_document => false }

This creates a document that requires the password 'foo' to be opened,
and cannot be printed without entering the owner password 'bar'.

If you want to prohibit most anyone from performing a certain activity, you can
pass :owner_password => :random to generate a probably-unguessable owner 

== Resources

=== Examples:

=== Bug Tracker:

=== Source Code:

=== Mailing List:

=== IRC:

Find us in #prawn on
  Gregory Brown: <sandal>
  James Healy: <yob>               
  Brad Ediger: <bradediger>
  Daniel Nelson: <bluejade>
== Notes to Developers: 

See HACKING file for details on getting set up with a local build.

Something went wrong with that request. Please try again.