Class TextElement
Represents a textual element optionally associated with a bounding box. Suitable for layout-aware text extraction from OCR engines, documents, or other structured sources.
[Obfuscation(Exclude = true)]
public sealed class TextElement : ILayoutElement, IBounds
- Inheritance
-
TextElement
- Implements
- Inherited Members
Examples
Example 1: Create a text element with position and size.
using LMKit.Document.Layout;
var element = new TextElement("Hello", left: 72, top: 100, width: 50, height: 12);
Console.WriteLine($"Text : {element.Text}");
Console.WriteLine($"Left : {element.Left}");
Console.WriteLine($"Top : {element.Top}");
Console.WriteLine($"Size : {element.Width} x {element.Height}");
Console.WriteLine($"Empty : {element.IsEmpty}");
Example 2: Create a text-only element (no bounding box).
using LMKit.Document.Layout;
var element = new TextElement("World");
Console.WriteLine(element.Text); // "World"
Console.WriteLine(element.IsEmpty); // true (zero-area bounding box)
Constructors
- TextElement(string)
Initializes a new instance of the TextElement class with only the text content. Bounding box values will default to 0.
- TextElement(string, Quadrilateral, double)
Initializes a new instance of the TextElement class with the specified text and an existing quadrilateral bounding box.
- TextElement(string, Quadrilateral, int, double, double)
Initializes a new instance of the TextElement class with the specified text and an existing quadrilateral bounding box, then rotates that box by
standardRotationdegrees around the center of a page.
- TextElement(string, double, double, double, double, double)
Initializes a new instance of the TextElement class with the specified text and bounding box coordinates.
- TextElement(string, double, double, double, double, int, double, double)
Initializes a new instance of the TextElement class with the specified text and bounding box coordinates, then rotates that box by
standardRotationdegrees around the center of a page.
Properties
- Angle
Orientation of the text in degrees, clockwise, relative to the page's unrotated axes. 0 = upright text; positive rotates clockwise.
- Bottom
Gets the vertical position of the bottom edge of the bounding box. If no bounding box is available, this value defaults to 0.
- Bounds
Returns the bounding quadrilateral of this text element.
- Height
Gets the height of the bounding box. If no bounding box is available, this value defaults to 0.
- IsEmpty
Gets a value indicating whether this text element is empty, i.e. has no text content or a zero-area bounding box.
- Left
Gets the horizontal position of the left edge of the bounding box. If no bounding box is available, this value defaults to 0.
- MidX
Gets the X-coordinate of the midpoint of the bounding box.
- MidY
Gets the Y-coordinate of the midpoint of the bounding box.
- Right
Gets the horizontal position of the right edge of the bounding box. If no bounding box is available, this value defaults to 0.
- Text
Gets the textual content of this element.
- Top
Gets the vertical position of the top edge of the bounding box. If no bounding box is available, this value defaults to 0.
- Width
Gets the width of the bounding box. If no bounding box is available, this value defaults to 0.
Methods
- Clone()
Creates a deep copy of this TextElement instance.