Module: HexaPDF::Content::SmartTextExtractor::TextRunCollector

Included in:
TextRunProcessor
Defined in:
lib/hexapdf/content/smart_text_extractor.rb

Overview

This module provides the functionality for collecting the necessary TextRun instances for layouting the text.

To use this module include it in a processor class. Then invoke the #collect_text_runs method in the #show_text and #show_text_with_positioning methods.

Example:

class CustomProcessor < HexaPDF::Content::Processor
  include TextRunCollector

  def show_text(str)
    collect_text_runs(decode_text_with_positioning(str))
  end
  alias show_text_with_positioning show_text

end

Once the processor has done its job, the collected text runs are available via the #text_runs method. Use them as input for SmartTextExtractor.layout_text_runs.

Defined Under Namespace

Classes: TextRun

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#text_runsObject (readonly)

Array with all collected TextRun instances.



101
102
103
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 101

def text_runs
  @text_runs
end

Instance Method Details

#initializeObject

:nodoc:



103
104
105
106
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 103

def initialize # :nodoc:
  super
  @text_runs = []
end