### Home Classes Methods

### In Files

- lib/prawn/stamp.rb

### Methods

- #create_stamp
- #stamp
- #stamp_at

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# Prawn::Stamp

The Prawn::Stamp module is used to create content that will be included multiple times in a document. Using a stamp has three advantages over creating content anew each time it is placed on the page:

    i.   faster document creation
    ii.  smaller final document
    iii. faster display on subsequent displays of the repeated
    element because the viewer application can cache the rendered
    results

Example:

    pdf.create_stamp("my_stamp") {
      pdf.fill_circle([10, 15], 5)
      pdf.draw_text("hello world", :at => [20, 10])
    }
    pdf.stamp("my_stamp")

### Public Instance Methods

create_stamp(name, &block) click to toggle source

Creates a re-usable stamp named `name`

raises `Prawn::Errors::NameTaken` if a stamp already exists in this document with this name raises `Prawn::Errors::InvalidName` if name.empty?

Example:

    pdf.create_stamp("my_stamp") {
      pdf.fill_circle([10, 15], 5)
      pdf.draw_text("hello world", :at => [20, 10])
    }

    # File lib/prawn/stamp.rb, line 79
    def create_stamp(name, &block)
      dictionary = create_stamp_dictionary(name)

      state.page.stamp_stream(dictionary, &block)
    end

stamp(name) click to toggle source

Renders the stamp named `name` to the page raises `Prawn::Errors::InvalidName` if name.empty? raises `Prawn::Errors::UndefinedObjectName` if no stamp has been created with this name

Example:

    pdf.create_stamp("my_stamp") {
      pdf.fill_circle([10, 15], 5)
      pdf.text("hello world", :at => [20, 10])
    }
    pdf.stamp("my_stamp")

    # File lib/prawn/stamp.rb, line 44
    def stamp(name)
      dictionary_name, dictionary = stamp_dictionary(name)
      add_content "/#{dictionary_name} Do"
      state.page.xobjects.merge!(dictionary_name => dictionary)
    end

stamp_at(name, point) click to toggle source

Renders the stamp named `name` at a position offset from the initial coords at which the elements of the stamp was created

Example:

    pdf.create_stamp("circle") do
      pdf.fill_circle([0, 0], 25)
    end
    # draws a circle at 100, 100
    pdf.stamp_at("circle", [100, 100])

See stamp() for exceptions that might be raised

    # File lib/prawn/stamp.rb, line 63
    def stamp_at(name, point)
      translate(point[0], point[1]) { stamp(name) }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.