Class LineElement
Represents a single, laid-out line of text within a document.
public sealed class LineElement : ILayoutElement, IBounds
- Inheritance
-
LineElement
- Implements
- Inherited Members
Examples
Example: Detect lines and iterate words.
using LMKit.Document.Layout;
using LMKit.Document.Pdf;
PdfInfo info = PdfInfo.Load("invoice.pdf");
PageElement page = info.Pages[0].GetLayout();
IList<LineElement> lines = page.DetectLines();
foreach (LineElement line in lines)
{
Console.WriteLine($"Line: "{line.Text}"");
Console.WriteLine($" Bounds: {line.Bounds}");
Console.WriteLine($" Words : {line.Words.Count}");
foreach (TextElement word in line.Words)
{
Console.Write($" [{word.Text}]");
}
Console.WriteLine();
}
Remarks
A LineElement aggregates one or more word-level items (see Words) and exposes their combined text as well as the union of their geometry via Bounds. Coordinates are expressed in the layout engine’s coordinate system.
Properties
- Bottom
Gets the maximum Y coordinate of the line’s bounding box.
- Bounds
Returns the line’s bounding quadrilateral.
- DominantTextAngleDegrees
Dominant text angle for this line in degrees, clockwise, normalized to[0, 360). Computed as a robust circular statistic over the word angles.
- Height
Gets the height of the line’s bounding box.
- Left
Gets the minimum X coordinate of the line’s bounding box.
- MidX
Gets the horizontal midpoint between the left and right edges.
- MidY
Gets the vertical midpoint between the top and bottom edges.
- Right
Gets the maximum X coordinate of the line’s bounding box.
- Text
Gets the full text content of the line.
- TextDirection
Coarse text flow direction of this line, derived from DominantTextAngleDegrees.
- Top
Gets the minimum Y coordinate of the line’s bounding box.
- Width
Gets the width of the line’s bounding box.
- Words
Gets the ordered collection of word-level items that compose this line.