Skip to content

Instantly share code, notes, and snippets.

@giuseb
Created December 2, 2011 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuseb/1424200 to your computer and use it in GitHub Desktop.
Save giuseb/1424200 to your computer and use it in GitHub Desktop.
Example of multiple indents across columns with Prawn
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'prawn', 'lib'))
require 'rubygems'
require 'prawn'
require 'prawn/security'
require "prawn/layout"
Prawn.debug = true
Prawn::Document.generate "column_indent_bug.pdf" do
column_box([0, cursor], width: 500, height: 700, columns: 3, spacer: 25) do
font_size 10
3.times do
stroke_bounds
text "No indent", style: :bold
text "left_side #{bounds.left_side}", style: :italic
text "left #{bounds.left}; right #{bounds.right}", style: :italic
text "width #{bounds.width}", style: :italic
text "Loremipsumdolorsitamet,consecteturadipisicingelit,seddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua.Utenimadminimveniam,quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat."
indent(20,10) do
text "Indent 20, 10", style: :bold
text "left_side #{bounds.left_side}", style: :italic
text "left #{bounds.left}; right #{bounds.right}", style: :italic
text "width #{bounds.width}", style: :italic
text "Loremipsumdolorsitamet,consecteturadipisicingelit,seddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua.Utenimadminimveniam,quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat."
indent(10, -10) do
text "Indent 10, -10", style: :bold
text "left #{bounds.left}; right #{bounds.right}", style: :italic
text "width #{bounds.width}", style: :italic
text "Loremipsumdolorsitamet,consecteturadipisicingelit,seddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua.Utenimadminimveniam,quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat."
end
text "done indenting"
end
text "done indenting"
bounds.move_past_bottom
end
end
end
system "open column_indent_bug.pdf"
puts "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment