Created
May 11, 2009 17:37
-
-
Save amoeba/110063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prawn' | |
require 'prawn/layout' | |
Prawn::Document.generate("table-test2.pdf") do | |
headers = ["Course", "Grade", "Comments"] | |
data = [] | |
10.times { |i| data << ["Home Room", "A+", "Great work!"]} | |
def make_table(headers, data) | |
table( | |
data, | |
:headers => headers, | |
:font_size => 8, | |
:border_style => :grid, | |
:border_width => 0.5, | |
:width => bounds.width) | |
end | |
text "Report for all students", :size => 22 | |
# Left column w/ some padding | |
bounding_box([bounds.left, bounds.top - 32], :width => bounds.width / 2 - 16) do | |
3.times do |i| | |
text "Student Name Here" | |
move_down 4 # So the student's name isn't so close to the table | |
make_table(headers, data[0..rand(10)]) | |
move_down 16 # So the next student's name isn't so close to this table | |
end | |
end | |
# Right column w/ some padding | |
bounding_box([bounds.left + bounds.width / 2 + 16, bounds.top - 32], :width => bounds.width / 2 - 16) do | |
3.times do |i| | |
text "Student Name Here" | |
move_down 4 # So the student's name isn't so close to the table | |
make_table(headers, data[0..rand(10)]) | |
move_down 16 # So the next student's name isn't so close to this table | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment