Method GetTextAsync
GetTextAsync(CancellationToken)
Asynchronously extracts and returns the textual content from the attachment.
public Task<string> GetTextAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to monitor for cancellation requests. Default: None.
Returns
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
modeTextOutputModeControls how raw lines are grouped and spaced in the output. See TextOutputMode: RawLines, GridAligned, or ParagraphFlow.
cancellationTokenCancellationTokenA 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