Sha256: 7b81f0fe39ac08a8b4ed62c2a3e93e86a3b34b734172b9c291e9397c01966d05

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

# encoding: utf-8
#
# This example demonstrates how to make use of Prawn's repeating element
# support.  Note that all repeated elements are generated using XObjects, so
# they should be pretty efficient.
#
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

Prawn::Document.generate("repeat.pdf", :skip_page_creation => true) do

  repeat :all do
    draw_text "ALLLLLL", :at => bounds.top_left
  end

  repeat :odd do
    draw_text "ODD", :at => [0,0]
  end

  repeat :even do
    draw_text "EVEN", :at => [0,0]
  end

  repeat [1,2] do 
    draw_text "[1,2]", :at => [100,0]
  end

  repeat 2..4 do
    draw_text "2..4", :at => [200,0]
  end

  repeat(lambda { |pg| pg % 3 == 0 }) do
    draw_text "Every third", :at => [250, 20]
  end
  
  repeat(:all, :dynamic => true) do
    draw_text page_number, :at => [500, 0]
  end

  10.times do 
    start_new_page
    draw_text "A wonderful page", :at => [400,400]
  end

end


Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
prawn-0.11.1 examples/general/repeaters.rb
davebenvenuti-prawn-0.11.1.pre examples/general/repeaters.rb