lib/pdf/reader/page_layout.rb in pdf-reader-1.3.0 vs lib/pdf/reader/page_layout.rb in pdf-reader-1.3.1

- old
+ new

@@ -7,10 +7,12 @@ # # media box should be a 4 number array that describes the dimensions of the # page to be rendered as described by the page's MediaBox attribute class PageLayout def initialize(runs, mediabox) + raise ArgumentError, "a mediabox must be provided" if mediabox.nil? + @runs = merge_runs(runs) @mean_font_size = mean(@runs.map(&:font_size)) || 0 @mean_glyph_width = mean(@runs.map(&:mean_character_width)) || 0 @page_width = mediabox[2] - mediabox[0] @page_height = mediabox[3] - mediabox[1] @@ -56,14 +58,14 @@ def col_count @col_count ||= ((@page_width / @mean_glyph_width) * 1.05).floor end def row_multiplier - @row_multiplier ||= @page_height / row_count + @row_multiplier ||= @page_height.to_f / row_count.to_f end def col_multiplier - @col_multiplier ||= @page_width / col_count + @col_multiplier ||= @page_width.to_f / col_count.to_f end def mean(collection) if collection.size == 0 0