Skip to content

Instantly share code, notes, and snippets.

@HHRy
Created September 10, 2010 10:32
Show Gist options
  • Save HHRy/573423 to your computer and use it in GitHub Desktop.
Save HHRy/573423 to your computer and use it in GitHub Desktop.
Strange behaviour with Prawn
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')
@HHRy
Copy link
Author

HHRy commented Sep 10, 2010

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.

@HHRy
Copy link
Author

HHRy commented Sep 10, 2010

Adding more examples with the same data, it eventually starts working.

@HHRy
Copy link
Author

HHRy commented Sep 10, 2010

Changing the order of things around, it seems as if the first table is always empty.

@HHRy
Copy link
Author

HHRy commented Sep 10, 2010

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