Skip to content

Instantly share code, notes, and snippets.

@joshrickard
Created March 16, 2012 10:57
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 joshrickard/2049584 to your computer and use it in GitHub Desktop.
Save joshrickard/2049584 to your computer and use it in GitHub Desktop.
Ruby Prawn - horizontally & vertically center a table within its container
# inspiration from: https://gist.github.com/2045188
# horizontally & vertically center a table within its container
t = make_table(table_data, { :position => :center })
move_down((bounds.height - t.height) / 2.0)
t.draw
# calculate the table's offset from its container
x_offset = (bounds.width - t.width) / 2
y_offset = (bounds.height - t.height) / 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment