Class: HexaPDF::Content::SmartTextExtractor::TextRunCollector::TextRun

Inherits:
Struct
  • Object
show all
Defined in:
lib/hexapdf/content/smart_text_extractor.rb

Overview

Represents a single run of continuous glyphs and their combined bounding box in user space.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom

Returns:

  • (Object)

    the current value of bottom



82
83
84
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 82

def bottom
  @bottom
end

#leftObject

Returns the value of attribute left

Returns:

  • (Object)

    the current value of left



82
83
84
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 82

def left
  @left
end

#rightObject

Returns the value of attribute right

Returns:

  • (Object)

    the current value of right



82
83
84
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 82

def right
  @right
end

#stringObject

Returns the value of attribute string

Returns:

  • (Object)

    the current value of string



82
83
84
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 82

def string
  @string
end

#topObject

Returns the value of attribute top

Returns:

  • (Object)

    the current value of top



82
83
84
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 82

def top
  @top
end

Instance Method Details

#baselineObject

The “baseline” is approximated with the bottom of the bounding box.

This works because HexaPDF uses a font’s bounding box instead of the glyph’s bounding box for each glyph. So while differently sized glyphs will have different “baseline” values, this is taken into account in the algorithm in the same way as subscript and superscript.

Using this “fake” baseline works well enough and avoids additional calculations.



91
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 91

def baseline = bottom

#heightObject

The height of the text run’s bounding box.



94
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 94

def height = top - bottom

#widthObject

The width of the text run’s bounding box.



97
# File 'lib/hexapdf/content/smart_text_extractor.rb', line 97

def width = right - left