Table of Contents

Class OdtStreamReader

Namespace
OdfKit.Text
Assembly
OdfKit.dll

Reads an ODT text document paragraph by paragraph in a low-memory streaming fashion, suitable for text extraction from large documents. 以低記憶體流式方式逐段落讀取 ODT 文字文件,適用於大型文件文字擷取。

public sealed class OdtStreamReader : IDisposable
Inheritance
OdtStreamReader
Implements
Inherited Members

Constructors

OdtStreamReader(Stream)

Initializes a new instance of the OdtStreamReader class from a stream. 從資料流初始化 OdtStreamReader 類別的新執行個體。

public OdtStreamReader(Stream stream)

Parameters

stream Stream

The ODT file stream. / ODT 檔案資料流。

Exceptions

ArgumentNullException

Thrown when stream is null. / 當 stream 為 null 時擲出。

OdtStreamReader(Stream, OdtStreamReaderOptions)

Initializes a reader from a stream with explicit resource limits. 使用明確資源限制,從資料流初始化讀取器。

public OdtStreamReader(Stream stream, OdtStreamReaderOptions options)

Parameters

stream Stream

The ODT file stream. / ODT 檔案資料流。

options OdtStreamReaderOptions

The reader options. / 讀取器選項。

OdtStreamReader(string)

Initializes a new instance of the OdtStreamReader class from a file path. 從檔案路徑初始化 OdtStreamReader 類別的新執行個體。

public OdtStreamReader(string path)

Parameters

path string

The ODT file path. / ODT 檔案路徑。

Exceptions

ArgumentNullException

Thrown when path is null. / 當 path 為 null 時擲出。

OdtStreamReader(string, OdtStreamReaderOptions)

Initializes a reader from a path with explicit resource limits. 使用明確資源限制,從路徑初始化讀取器。

public OdtStreamReader(string path, OdtStreamReaderOptions options)

Parameters

path string

The ODT file path. / ODT 檔案路徑。

options OdtStreamReaderOptions

The reader options. / 讀取器選項。

Properties

HeadingLevel

Gets the heading level, valid only when NodeType is Heading. 取得標題層級,僅在 NodeTypeHeading 時有效。

public int HeadingLevel { get; }

Property Value

int

NodeType

Gets the type of the current element. 取得目前元素的類型。

public OdtNodeType NodeType { get; }

Property Value

OdtNodeType

StyleName

Gets the paragraph style name of the current element. 取得目前元素的段落樣式名稱。

public string? StyleName { get; }

Property Value

string

Text

Gets the plain text content of the current element, including embedded text:span text. 取得目前元素的純文字內容,包含內嵌 text:span 文字。

public string Text { get; }

Property Value

string

Methods

Dispose()

Releases the reader and underlying ZIP resources. 釋放讀取器與底層 ZIP 資源。

public void Dispose()

Read()

Reads the next text element; returns false to indicate the end of the document. 讀取下一個文字元素;回傳 false 代表文件結束。

public bool Read()

Returns

bool

true if an element was successfully read; otherwise false. / 若成功讀取元素則為 true,否則為 false。

ReadAsync(CancellationToken)

Asynchronously reads the next text element and observes cancellation during XML traversal. 非同步讀取下一個文字元素,並在 XML 走訪期間回應取消要求。

public Task<bool> ReadAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

Task<bool>

true when an element is available; otherwise, false. / 有可用元素時為 true;否則為 false