Created
September 10, 2010 10:32
-
-
Save HHRy/573423 to your computer and use it in GitHub Desktop.
Strange behaviour with Prawn
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 'rubygems' | |
require 'prawn' | |
pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape) | |
pdf.bounding_box [0, pdf.bounds.height - 40,], :width => 740 do | |
# No Entries | |
# | |
pdf.table([["Total Value of Spend", "Total Transactions", "Average Transaction Value"], ["4558.5100", "30", "151.95033333"]], :header => true) do | |
row(0).style(:style => :bold, :background_color => 'cccccc') | |
end | |
pdf.move_down(10) | |
# Works | |
# | |
pdf.table([["Total Value of Spend", "Total Transactions", "Average Transaction Value"], ["4558.5100", "30", "151.95033333"]]) | |
pdf.move_down(10) | |
# Works. | |
# | |
pdf.table([["Total Value of Spend", "Total Transactions", "Average Transaction Value"], ["4558.5100", "30", "151.95033333"]], :header => true, :cell_style => { :borders => [] }) | |
pdf.move_down(10) | |
# Suddenly Works | |
# | |
pdf.table([["Total Value of Spend", "Total Transactions", "Average Transaction Value"], ["4558.5100", "30", "151.95033333"]], :header => true) do | |
row(0).style(:style => :bold, :background_color => 'cccccc') | |
end | |
end | |
pdf.render_file('test.pdf') |
Adding more examples with the same data, it eventually starts working.
Changing the order of things around, it seems as if the first table is always empty.
Removing the Bounding box solves the problem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to upgrade some Prawn 0.8.4 to 0.10.2 so I can use more of the nifty table / layout stuff in a project, when I ran into this simplified problem. The generated table contains absolutely no data.
Ruby 1.8.7 and prawn 0.10.2 gem.