Sha256: 93ae2747f1355e72641501df8bd7df9c53b757657646b1f0fa9f5f795385ca15

Contents?: true

Size: 1.44 KB

Versions: 20

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8
#
# This example demonstrates how nested bounding boxes work when the outer box is
# stretchy and includes several inner boxes of different sizes.

require "#{File.dirname(__FILE__)}/../example_helper.rb"

Prawn::Document.generate("stretched_nesting.pdf", :page_layout => :landscape) do

  def stroke_dashed_bounds
    dash(1)
    stroke_bounds
    undash
  end

  bounding_box [100,400], :width => 500 do

    bounding_box [0, bounds.top], :width => 200, :height => 100 do
      stroke_bounds
    end

    bounding_box [200, bounds.top], :width => 150 do
      indent(5) do
        text "This box is longest, so it stretches the parent box. \n"*5
      end
    end

    bounding_box [350, bounds.top], :width => 150 do
      text "I AM SANTA CLAUS!!!"
    end

    stroke_dashed_bounds

  end

  bounding_box [100, 250], :width => 500 do

    bounding_box [0, bounds.top], :width => 100, :height => 100 do
      text "1"
      stroke_bounds
    end

    bounding_box [125, bounds.top], :width => 50, :height => 25 do
      text "2"
      stroke_bounds
    end

    bounding_box [200, bounds.top - 50], :width => 50, :height => 125 do
      text "3"
      stroke_bounds
    end

    bounding_box [350, bounds.top - 100], :width => 20, :height => 20 do
      text "4"
      stroke_bounds
    end

    bounding_box [400, bounds.height - 150], :width => 100, :height => 100 do
      text "5"
      stroke_bounds
    end

    stroke_dashed_bounds

  end

end

Version data entries

20 entries across 20 versions & 7 rubygems

Version Path
piglop-prawn-0.10.2.3 examples/bounding_box/stretched_nesting.rb
piglop-prawn-0.10.2.2 examples/bounding_box/stretched_nesting.rb
piglop-prawn-0.10.2.1 examples/bounding_box/stretched_nesting.rb
prawn-0.11.1.pre examples/bounding_box/stretched_nesting.rb
goodwill-prawn-edge-0.10.0 examples/bounding_box/stretched_nesting.rb
alphasights-prawn-0.10.4 examples/bounding_box/stretched_nesting.rb
alphasights-prawn-0.10.3 examples/bounding_box/stretched_nesting.rb
alphasights-prawn-0.10.2 examples/bounding_box/stretched_nesting.rb
alphasights-prawn-0.10.1 examples/bounding_box/stretched_nesting.rb
alphasights-prawn-0.10.0 examples/bounding_box/stretched_nesting.rb
prawn-core-0.8.4 examples/bounding_box/stretched_nesting.rb
prawn-graph-0.0.2 vendor/prawn-core/examples/bounding_box/stretched_nesting.rb
prawn-graph-0.0.1 vendor/prawn-core/examples/bounding_box/stretched_nesting.rb
prawn-core-0.7.2 examples/bounding_box/stretched_nesting.rb
prawn-core-0.7.1 examples/bounding_box/stretched_nesting.rb
prawn-layout-0.3.2 vendor/prawn-core/examples/bounding_box/stretched_nesting.rb
prawn-core-0.6.3 examples/bounding_box/stretched_nesting.rb
prawn-core-0.6.2 examples/bounding_box/stretched_nesting.rb
prawn-layout-0.3.1 vendor/prawn-core/examples/bounding_box/stretched_nesting.rb
prawn-core-0.6.1 examples/bounding_box/stretched_nesting.rb