Sha256: f23940fb69fc5a5759bc18133ae8b8b60354123fc02a6f81f63b870cc931f247

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

# encoding: utf-8

# Shows how to use the style() method with a block to style each cell with
# custom code.

require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))
 
Prawn::Document.generate("checkerboard.pdf") do 

  text "Here is a checkerboard:"

  table [[""] * 8] * 8 do |t|
    t.cells.style :width => 24, :height => 24
    t.cells.style do |c| 
      c.background_color = ((c.row + c.column) % 2).zero? ? '000000' : 'ffffff'
    end
  end

  move_down 12
  text "Hope you enjoyed it!"

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
prawn-0.11.1 examples/table/checkerboard.rb
davebenvenuti-prawn-0.11.1.pre examples/table/checkerboard.rb