### Home Classes Methods

### In Files

- lib/prawn/document/graphics_state.rb

### Methods

- #restore_graphics_state
- #save_graphics_state

### Files

- COPYING
- HACKING
- LICENSE
- README

### Class/Module Index

Quicksearch

- 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

No matching classes.

# Prawn::Document::GraphicsState

### Public Instance Methods

restore_graphics_state() click to toggle source

Pops the last saved graphics state off the graphics state stack and restores the state to those values

    # File lib/prawn/document/graphics_state.rb, line 42
    def restore_graphics_state
      add_content "Q"
    end

save_graphics_state() click to toggle source

Pushes the current graphics state on to the graphics state stack so we can restore it when finished with a change we want to isolate (such as modifying the transformation matrix). Used in pairs with restore_graphics_state or passed a block

Example without a block:

    save_graphics_state
    rotate 30
    text "rotated text"
    restore_graphics_state

Example with a block:

    save_graphics_state do
      rotate 30
      text "rotated text"
    end

    # File lib/prawn/document/graphics_state.rb, line 32
    def save_graphics_state
      add_content "q"
      if block_given?
        yield
        restore_graphics_state
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.