# prawn-core-0.8.4 Documentation

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: rubymendicant.wikidot.com

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 = Prawn::Document.new
    pdf.text("Prawn Rocks")
    pdf.render_file('prawn.pdf')

But prawn can do a lot more:

### Any page size you can think of

    Prawn::Document.new('A0')

...gives you an really big page.

    Prawn::Document.new(:page_size   => [11.32, 8.49],
                        :page_layout => :portrait)

...giving you a postage stamp.

Learn more

### Multiple Font Handling with UTF-8 Support

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

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

Learn more

### Drawing graphics directly into the page

Simple shapes:

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

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

Learn more

### 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("http://prawn.majesticseacreature.com/media/prawn_logo.png")

Learn more

### 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 => 10.mm,    # different
                        :right_margin => 1.cm,    # units
                        :top_margin => 0.1.dm,    # work
                        :bottom_margin => 0.01.m, # well
                        :page_size => 'A4') do
      text "Prawn Rocks"
    end

Learn more

## Resources

### Website:

prawn.majesticseacreature.com

### Examples:

github.com/sandal/prawn/tree/stable/examples

For tables and grid based layout:

github.com/sandal/prawn-layout/tree/stable/examples

For encryption, password protection, and permissions:

github.com/madriska/prawn-security/tree/stable/examples

(or gem unpack prawn-core, prawn-security and prawn-layout if you want to run them locally)

### Bug Tracker / Wiki:

github.com/sandal/prawn/issues github.com/sandal/prawn-layout/issues github.com/madriska/prawn-security/issues

### Source Code:

github.com/sandal/prawn github.com/sandal/prawn-layout github.com/madriska/prawn-security

### Mailing List:

groups.google.com/group/prawn-ruby

### IRC:

Find us in prawn on irc.freenode.net

    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.

## Files

- COPYING
- HACKING
- LICENSE
- README

## Classes/Modules

- Prawn
- Prawn::Core
- Prawn::Document
- Prawn::Document::Annotations
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::Destinations
- Prawn::Document::GraphicsState
- Prawn::Document::Internals
- Prawn::Document::PageGeometry
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::Images
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::Outline
- Prawn::Stamp
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::LineWrap
- File
- Numeric

## Methods

- ::binread — File
- ::extensions — Prawn::Document
- ::font_count — Prawn::Font::DFont
- ::generate — Prawn::Document
- ::load — Prawn::Font
- ::metrics_path — Prawn::Font::AFM
- ::named_fonts — Prawn::Font::DFont
- ::new — Prawn::Document
- ::new — Prawn::Images::PNG
- ::new — Prawn::Images::JPG
- ::new — Prawn::Outline
- ::new — Prawn::Text::Box
- ::new — Prawn::Font::TTF
- #PdfObject — Prawn
- #absolute_bottom — Prawn::Document::BoundingBox
- #absolute_bottom_left — Prawn::Document::BoundingBox
- #absolute_bottom_right — Prawn::Document::BoundingBox
- #absolute_left — Prawn::Document::BoundingBox
- #absolute_right — Prawn::Document::BoundingBox
- #absolute_top — Prawn::Document::BoundingBox
- #absolute_top_left — Prawn::Document::BoundingBox
- #absolute_top_right — Prawn::Document::BoundingBox
- #add_content — Prawn::Document::Internals
- #add_dest — Prawn::Document::Destinations
- #add_section — Prawn::Outline
- #add_to_current_page — Prawn::Font
- #anchor — Prawn::Document::BoundingBox
- #annotate — Prawn::Document::Annotations
- #ascender — Prawn::Font
- #basename — Prawn::Font::TTF
- #bbox — Prawn::Font::TTF
- #bbox — Prawn::Font::AFM
- #before_render — Prawn::Document::Internals
- #bottom — Prawn::Document::BoundingBox
- #bottom_left — Prawn::Document::BoundingBox
- #bottom_right — Prawn::Document::BoundingBox
- #bounding_box — Prawn::Document
- #bounds — Prawn::Document
- #bounds= — Prawn::Document
- #canvas — Prawn::Document
- #cap_height — Prawn::Font::TTF
- #cap_style — Prawn::Graphics::CapStyle
- #cap_style= — Prawn::Graphics::CapStyle
- #circle_at — Prawn::Graphics
- #cm — Numeric
- #cm2mm — Prawn::Measurements
- #cm2pt — Prawn::Measurements
- #colors — Prawn::Images::PNG
- #column_box — Prawn::Document
- #compression_enabled? — Prawn::Document
- #create_stamp — Prawn::Stamp
- #cursor — Prawn::Document
- #curve — Prawn::Graphics
- #curve_to — Prawn::Graphics
- #dash — Prawn::Graphics::Dash
- #dash= — Prawn::Graphics::Dash
- #dashed? — Prawn::Graphics::Dash
- #define — Prawn::Outline
- #define_outline — Prawn::Document
- #descender — Prawn::Font
- #dest_fit — Prawn::Document::Destinations
- #dest_fit_bounds — Prawn::Document::Destinations
- #dest_fit_bounds_horizontally — Prawn::Document::Destinations
- #dest_fit_bounds_vertically — Prawn::Document::Destinations
- #dest_fit_horizontally — Prawn::Document::Destinations
- #dest_fit_rect — Prawn::Document::Destinations
- #dest_fit_vertically — Prawn::Document::Destinations
- #dest_xyz — Prawn::Document::Destinations
- #dests — Prawn::Document::Destinations
- #dm — Numeric
- #dm2mm — Prawn::Measurements
- #dm2pt — Prawn::Measurements
- #draw_text — Prawn::Text
- #ellipse_at — Prawn::Graphics
- #encode_text — Prawn::Font::TTF
- #encode_text — Prawn::Font::AFM
- #family_class — Prawn::Font::TTF
- #fill — Prawn::Graphics
- #fill_and_stroke — Prawn::Graphics
- #fill_color — Prawn::Graphics::Color
- #fill_color= — Prawn::Graphics::Color
- #float — Prawn::Document
- #font — Prawn::Document
- #font_families — Prawn::Document
- #font_size — Prawn::Document
- #ft — Numeric
- #ft2in — Prawn::Measurements
- #ft2pt — Prawn::Measurements
- #go_to_page — Prawn::Document
- #group — Prawn::Document
- #has_kerning_data? — Prawn::Font::TTF
- #has_kerning_data? — Prawn::Font::AFM
- #height — Prawn::Text::Box
- #height — Prawn::Document::BoundingBox
- #height — Prawn::Font
- #height_at — Prawn::Font
- #height_of — Prawn::Text
- #hex2rgb — Prawn::Graphics::Color
- #horizontal_line — Prawn::Graphics
- #horizontal_rule — Prawn::Graphics
- #image — Prawn::Images
- #in — Numeric
- #in2pt — Prawn::Measurements
- #indent — Prawn::Document
- #indent — Prawn::Document::BoundingBox
- #insert_section_after — Prawn::Outline
- #italic_angle — Prawn::Font::TTF
- #join_style — Prawn::Graphics::JoinStyle
- #join_style= — Prawn::Graphics::JoinStyle
- #left — Prawn::Document::BoundingBox
- #left_side — Prawn::Document::ColumnBox
- #left_side — Prawn::Document::BoundingBox
- #line — Prawn::Graphics
- #line_gap — Prawn::Font
- #line_to — Prawn::Graphics
- #line_width — Prawn::Graphics
- #line_width= — Prawn::Graphics
- #link_annotation — Prawn::Document::Annotations
- #m — Numeric
- #m2mm — Prawn::Measurements
- #m2pt — Prawn::Measurements
- #method_missing — Prawn::Graphics::Color
- #mm — Numeric
- #mm2pt — Prawn::Measurements
- #move_cursor_to — Prawn::Document
- #move_down — Prawn::Document
- #move_past_bottom — Prawn::Document::ColumnBox
- #move_past_bottom — Prawn::Document::BoundingBox
- #move_to — Prawn::Graphics
- #move_up — Prawn::Document
- #names — Prawn::Document::Internals
- #names? — Prawn::Document::Internals
- #normalize_encoding — Prawn::Font::AFM
- #normalize_encoding — Prawn::Font
- #normalize_encoding — Prawn::Font::TTF
- #normalize_encoding! — Prawn::Font
- #number_pages — Prawn::Document
- #on_page_create — Prawn::Document::Internals
- #outline — Prawn::Document
- #outline_root — Prawn::Document
- #pad — Prawn::Document
- #pad_bottom — Prawn::Document
- #pad_top — Prawn::Document
- #page_count — Prawn::Document
- #page_number — Prawn::Document
- #pdf_flags — Prawn::Font::TTF
- #pixel_bitlength — Prawn::Images::PNG
- #polygon — Prawn::Graphics
- #pt — Numeric
- #pt2mm — Prawn::Measurements
- #rectangle — Prawn::Graphics
- #ref — Prawn::Document::Internals
- #ref! — Prawn::Document::Internals
- #render — Prawn::Document
- #render — Prawn::Text::Box
- #render_file — Prawn::Document
- #repeat — Prawn::Document
- #repeaters — Prawn::Document
- #restore_graphics_state — Prawn::Document::GraphicsState
- #rgb2hex — Prawn::Graphics::Color
- #right — Prawn::Document::BoundingBox
- #right_side — Prawn::Document::BoundingBox
- #right_side — Prawn::Document::ColumnBox
- #rollback — Prawn::Document::Snapshot
- #rotate — Prawn::Graphics::Transformation
- #rounded_polygon — Prawn::Graphics
- #rounded_rectangle — Prawn::Graphics
- #rounded_vertex — Prawn::Graphics
- #save_font — Prawn::Document
- #save_graphics_state — Prawn::Document::GraphicsState
- #scale — Prawn::Graphics::Transformation
- #script? — Prawn::Font::TTF
- #serif? — Prawn::Font::TTF
- #span — Prawn::Document
- #split_alpha_channel! — Prawn::Images::PNG
- #stamp — Prawn::Stamp
- #stamp_at — Prawn::Stamp
- #start_new_page — Prawn::Document
- #stemV — Prawn::Font::TTF
- #stretchy? — Prawn::Document::BoundingBox
- #stroke — Prawn::Graphics
- #stroke_bounds — Prawn::Graphics
- #stroke_color — Prawn::Graphics::Color
- #stroke_color= — Prawn::Graphics::Color
- #text — Prawn::Text
- #text_annotation — Prawn::Document::Annotations
- #text_box — Prawn::Text
- #top — Prawn::Document::BoundingBox
- #top_left — Prawn::Document::BoundingBox
- #top_right — Prawn::Document::BoundingBox
- #transaction — Prawn::Document::Snapshot
- #transformation_matrix — Prawn::Graphics::Transformation
- #translate — Prawn::Graphics::Transformation
- #transparent — Prawn::Graphics::Transparency
- #undash — Prawn::Graphics::Dash
- #unicode? — Prawn::Font::TTF
- #unicode? — Prawn::Font::AFM
- #update_height — Prawn::Document::BoundingBox
- #vertical_line — Prawn::Graphics
- #width — Prawn::Document::BoundingBox
- #width — Prawn::Document::ColumnBox
- #width_of — Prawn::Document
- #width_of_column — Prawn::Document::ColumnBox
- #wrap_line — Prawn::Text::LineWrap
- #x_height — Prawn::Font::TTF
- #y= — Prawn::Document
- #yd — Numeric
- #yd2in — Prawn::Measurements
- #yd2pt — Prawn::Measurements

[Validate]

Generated with the Darkfish Rdoc Generator 2.