Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ColumnBox puts spacers only between columns, not at end

Closes #302.
  • Loading branch information...
commit bd1cbd8f2984b4da423b07929851dd96c92a032c 1 parent 31f56be
@bradediger bradediger authored
Showing with 15 additions and 1 deletion.
  1. +2 −1  lib/prawn/document/column_box.rb
  2. +13 −0 spec/column_box_spec.rb
View
3  lib/prawn/document/column_box.rb
@@ -57,7 +57,8 @@ def initialize(document, parent, point, options={}) #:nodoc:
# how long a line of text can be.
#
def width
- super / @columns - @spacer - @total_left_padding - @total_right_padding
+ (super - @spacer * (@columns - 1)) / @columns -
+ (@total_left_padding + @total_right_padding)
end
# Column width including the spacer.
View
13 spec/column_box_spec.rb
@@ -17,4 +17,17 @@
@pdf.bounds.right.should.be > @pdf.bounds.left
end
end
+
+ it "includes spacers between columns but not at the end" do
+ create_pdf
+ @pdf.column_box [0, @pdf.cursor], :width => 500,
+ :height => 200, :columns => 3, :spacer => 25 do
+ @pdf.bounds.width.should == 150 # (500 - (25 * 2)) / 3
+
+ @pdf.bounds.move_past_bottom
+ @pdf.bounds.move_past_bottom
+
+ @pdf.bounds.right.should == 500
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.