Table of Contents

Method GetTextAsync

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

GetTextAsync(CancellationToken)

Asynchronously extracts and returns the textual content from the attachment.

public Task<string> GetTextAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to monitor for cancellation requests. Default: None.

Returns

Task<string>

A task whose result is the textual content; empty string if no text is available.

GetTextAsync(TextOutputMode, CancellationToken)

Asynchronously extracts and returns the textual content formatted with the given mode.

public Task<string> GetTextAsync(TextOutputMode mode, CancellationToken cancellationToken = default)

Parameters

mode TextOutputMode

Controls how raw lines are grouped and spaced in the output. See TextOutputMode: RawLines, GridAligned, or ParagraphFlow.

cancellationToken CancellationToken

A token to observe while performing extraction. If cancellation is requested, the operation throws OperationCanceledException.

Returns

Task<string>

A task that completes with the extracted plain-text content (UTF-8, Unix line endings) formatted according to mode; the result is an empty string when the attachment has no extractable text.

Remarks

The first invocation performs extraction and caches page elements; later calls reuse the cache. The layout mode is applied at formatting time without re-extracting text. For image-only inputs, provide OCR text via SetText(string) or SetText(PageElement) to obtain non-empty output. If you want the default layout, use GetTextAsync(CancellationToken).

See Also