Class ParagraphElement
Represents a paragraph in a document layout.
public sealed class ParagraphElement : ILayoutElement, IBounds
- Inheritance
-
ParagraphElement
- Implements
- Inherited Members
Examples
Example: Detect paragraphs and display their text.
using LMKit.Document.Layout;
using LMKit.Document.Pdf;
PdfInfo info = PdfInfo.Load("article.pdf");
PageElement page = info.Pages[0].GetLayout();
IList<ParagraphElement> paragraphs = page.DetectParagraphs();
for (int i = 0; i < paragraphs.Count; i++)
{
ParagraphElement para = paragraphs[i];
Console.WriteLine($"Paragraph {i + 1} ({para.Lines.Count} lines):");
Console.WriteLine($" Bounds : {para.Bounds}");
Console.WriteLine($" Direction: {para.TextDirection}");
Console.WriteLine($" Text : {para.Text.Substring(0, Math.Min(80, para.Text.Length))}...");
Console.WriteLine();
}
Remarks
A ParagraphElement aggregates one or more LineElement instances and exposes their combined text and bounding geometry. Coordinates are expressed in the same coordinate system as the source layout engine.
Properties
- Bottom
Gets the maximum Y coordinate of the paragraph’s bounding box.
- Bounds
Returns the paragraph’s bounding quadrilateral.
- DominantTextAngleDegrees
Dominant text angle for this paragraph in degrees, clockwise, normalized to [0, 360). Computed as a robust circular median over word angles.
- Height
Gets the height of the paragraph’s bounding box.
- LayerId
Gets the identifier of the source layer this paragraph belongs to.
- Left
Gets the minimum X coordinate of the paragraph’s bounding box.
- Lines
Gets the ordered collection of lines that compose this paragraph.
- 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 maximum X coordinate of the paragraph’s bounding box.
- Text
Gets the full paragraph text.
- TextDirection
Coarse paragraph direction derived from DominantTextAngleDegrees.
- Top
Gets the minimum Y coordinate of the paragraph’s bounding box.
- Width
Gets the width of the paragraph’s bounding box.
Methods
- ToString()
Returns a readable string that includes the paragraph text and its bounding box metrics.