Skip to content

Instantly share code, notes, and snippets.

@McPolemic
Created February 13, 2014 17: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 McPolemic/46507cb76fc07875e1b7 to your computer and use it in GitHub Desktop.
Save McPolemic/46507cb76fc07875e1b7 to your computer and use it in GitHub Desktop.
Statement Table Issues
require 'prawn'
def coupon_seperator(options={})
y = options[:y]
font "Helvetica", :align => :center do
move_cursor_to y
dash 1, :space => 3
stroke_horizontal_rule
undash
move_cursor_to y-5
text "Detach Here", :align => :center
text "(If you are already set up for automatic payments, please disregard this coupon.)", :align => :center
end
end
Prawn::Document.generate(filename="example.pdf") do
data = [["Column 1", "Column 2", "Column 3", "Column 4"]]
100.times {|i| data << ["Row #{i}", "Row #{i}", "Row #{i}", "Row #{i}"]}
coupon_seperator(:y => 235)
x = 100
y = 400
width = 500
height = 160
bounding_box([x,y], :width => width, :height => height) do
table(data, {:header => true}) do |t|
# Set up formatting for the header row
t.row(0).style :font_style => :bold,
:background_color => "000000",
:text_color => "FFFFFF"
end
end
end
require 'prawn'
def coupon_seperator(options={})
y = options[:y]
font "Helvetica", :align => :center do
move_cursor_to y
dash 1, :space => 3
stroke_horizontal_rule
undash
move_cursor_to y-5
text "Detach Here", :align => :center
text "(If you are already set up for automatic payments, please disregard this coupon.)", :align => :center
end
end
Prawn::Document.generate(filename="example.pdf") do
data = [["Column 1", "Column 2", "Column 3", "Column 4"]]
100.times {|i| data << ["Row #{i}", "Row #{i}", "Row #{i}", "Row #{i}"]}
coupon_seperator(:y => 235)
y = 400
width = 500
height = 160 # No way to specify height on a span
move_cursor_to y
span(width, :position => :center) do
table(data, {:header => true}) do |t|
# Set up formatting for the header row
t.row(0).style :font_style => :bold,
:background_color => "000000",
:text_color => "FFFFFF"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment