lib/pdf/reader/page_layout.rb in pdf-reader-2.2.1 vs lib/pdf/reader/page_layout.rb in pdf-reader-2.3.0
- old
+ new
@@ -1,8 +1,10 @@
# coding: utf-8
# frozen_string_literal: true
+require 'pdf/reader/overlapping_runs_filter'
+
class PDF::Reader
# Takes a collection of TextRun objects and renders them into a single
# string that best approximates the way they'd appear on a render PDF page.
#
@@ -13,10 +15,10 @@
DEFAULT_FONT_SIZE = 12
def initialize(runs, mediabox)
raise ArgumentError, "a mediabox must be provided" if mediabox.nil?
- @runs = merge_runs(runs)
+ @runs = merge_runs(OverlappingRunsFilter.exclude_redundant_runs(runs))
@mean_font_size = mean(@runs.map(&:font_size)) || DEFAULT_FONT_SIZE
@mean_font_size = DEFAULT_FONT_SIZE if @mean_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]