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.



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

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.



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

def items
  @items
end

Instance Method Details

#move_to_next_lineObject



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

def move_to_next_line; end

#non_stroke_alpha=(value) ⇒ Object



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

def non_stroke_alpha=(value)
  @non_stroke_alpha = value
end

#show_text(text) ⇒ Object



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

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



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

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



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

def stroke_alpha=(value)
  @stroke_alpha = value
end

#text_rendering_mode=(value) ⇒ Object



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

def text_rendering_mode=(value)
  @text_rendering_mode = value
end