Class: Pdfrb::Content::HiddenTextDetector::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfrb/content/hidden_text_detector.rb

Overview

Internal: collects text-show operations with their visibility state.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Collector

Returns a new instance of Collector.



116
117
118
119
120
121
122
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 116

def initialize(page)
  @items = []
  @page = page
  @text_rendering_mode = 0
  @non_stroke_alpha = 1.0
  @stroke_alpha = 1.0
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



114
115
116
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 114

def items
  @items
end

Instance Method Details

#move_to_next_lineObject



154
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 154

def move_to_next_line; end

#non_stroke_alpha=(value) ⇒ Object



128
129
130
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 128

def non_stroke_alpha=(value)
  @non_stroke_alpha = value
end

#show_text(text) ⇒ Object



136
137
138
139
140
141
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 136

def show_text(text)
  return if text.nil?

  reason = current_reason
  @items << HiddenItem.new(text: text.to_s, reason: reason, page: @page)
end

#show_text_array(items) ⇒ Object



143
144
145
146
147
148
149
150
151
152
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 143

def show_text_array(items)
  return unless items.is_a?(::Array)

  items.each do |item|
    if item.is_a?(::String)
      show_text(item)
    end
    # Numeric items are positioning values; ignore them
  end
end

#stroke_alpha=(value) ⇒ Object



132
133
134
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 132

def stroke_alpha=(value)
  @stroke_alpha = value
end

#text_rendering_mode=(value) ⇒ Object



124
125
126
# File 'lib/pdfrb/content/hidden_text_detector.rb', line 124

def text_rendering_mode=(value)
  @text_rendering_mode = value
end