Table of Contents

Class OdfDocumentFactory

Namespace
OdfKit.Core
Assembly
OdfKit.dll

Creates minimal low-level ODF packages and flat XML documents. 建立最小的低階 ODF 封裝與扁平 XML 文件。

public static class OdfDocumentFactory
Inheritance
OdfDocumentFactory
Inherited Members

Methods

CreateDocument(OdfDocumentKind)

Creates a high-level ODF document wrapper of the specified kind. 建立指定種類的高階 ODF 文件 wrapper。

public static OdfDocument CreateDocument(OdfDocumentKind kind)

Parameters

kind OdfDocumentKind

The ODF document kind to create. / 要建立的 ODF 文件種類。

Returns

OdfDocument

The created ODF document. / 建立完成的 ODF 文件。

CreatePackage(Stream, OdfDocumentKind)

Creates a minimally packaged ODF document in the provided stream. 在提供的資料流中建立一個最小封裝的 ODF 文件。

public static OdfPackage CreatePackage(Stream stream, OdfDocumentKind kind)

Parameters

stream Stream
kind OdfDocumentKind

Returns

OdfPackage

The created OdfPackage instance. / 傳回建立的 OdfPackage 執行個體。

CreatePackage(Stream, OdfDocumentKind, OdfVersion)

Short overload of CreatePackage that accepts stream, kind, and version; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、kind 與 version;其餘可選參數使用預設值並轉呼叫最長 CreatePackage 多載。

public static OdfPackage CreatePackage(Stream stream, OdfDocumentKind kind, OdfVersion version)

Parameters

stream Stream
kind OdfDocumentKind
version OdfVersion

Returns

OdfPackage

CreatePackage(Stream, OdfDocumentKind, OdfVersion, bool)

Short overload of CreatePackage that accepts stream, kind, version, and leaveOpen; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、kind、version 與 leaveOpen;其餘可選參數使用預設值並轉呼叫最長 CreatePackage 多載。

public static OdfPackage CreatePackage(Stream stream, OdfDocumentKind kind, OdfVersion version, bool leaveOpen)

Parameters

stream Stream
kind OdfDocumentKind
version OdfVersion
leaveOpen bool

Returns

OdfPackage

CreatePackage(Stream, OdfDocumentKind, OdfVersion, bool, OdfSaveOptions?)

Short overload of CreatePackage that accepts stream, kind, version, leaveOpen, and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、kind、version、leaveOpen 與 options;其餘可選參數使用預設值並轉呼叫最長 CreatePackage 多載。

public static OdfPackage CreatePackage(Stream stream, OdfDocumentKind kind, OdfVersion version, bool leaveOpen, OdfSaveOptions? options)

Parameters

stream Stream
kind OdfDocumentKind
version OdfVersion
leaveOpen bool
options OdfSaveOptions

Returns

OdfPackage

CreatePackage(Stream, OdfDocumentKind, bool)

Creates a minimally packaged ODF document in the provided stream with an explicit leave-open flag. 在提供的資料流中建立最小封裝 ODF 文件,並明確指定是否保持資料流開啟。

public static OdfPackage CreatePackage(Stream stream, OdfDocumentKind kind, bool leaveOpen)

Parameters

stream Stream

The destination stream. / 目標資料流。

kind OdfDocumentKind

The ODF document kind. / ODF 文件種類。

leaveOpen bool

Whether to leave the stream open after disposing the package. / 封裝釋放後是否保持資料流開啟。

Returns

OdfPackage

The created OdfPackage instance. / 傳回建立的 OdfPackage 執行個體。

CreatePackage(string, OdfDocumentKind)

Creates a minimally packaged ODF document at the provided path. 在提供的路徑上建立一個最小封裝的 ODF 文件。

public static OdfPackage CreatePackage(string path, OdfDocumentKind kind)

Parameters

path string
kind OdfDocumentKind

Returns

OdfPackage

The created OdfPackage instance. / 傳回建立的 OdfPackage 執行個體。

CreatePackage(string, OdfDocumentKind, OdfVersion)

Short overload of CreatePackage that accepts path, kind, and version; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path、kind 與 version;其餘可選參數使用預設值並轉呼叫最長 CreatePackage 多載。

public static OdfPackage CreatePackage(string path, OdfDocumentKind kind, OdfVersion version)

Parameters

path string
kind OdfDocumentKind
version OdfVersion

Returns

OdfPackage

CreatePackage(string, OdfDocumentKind, OdfVersion, OdfSaveOptions?)

Short overload of CreatePackage that accepts path, kind, version, and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path、kind、version 與 options;其餘可選參數使用預設值並轉呼叫最長 CreatePackage 多載。

public static OdfPackage CreatePackage(string path, OdfDocumentKind kind, OdfVersion version, OdfSaveOptions? options)

Parameters

path string
kind OdfDocumentKind
version OdfVersion
options OdfSaveOptions

Returns

OdfPackage

InitializeMinimalPackage(OdfPackage, OdfDocumentKind)

Short overload of InitializeMinimalPackage that accepts package and kind; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 package 與 kind;其餘可選參數使用預設值並轉呼叫最長 InitializeMinimalPackage 多載。

public static void InitializeMinimalPackage(OdfPackage package, OdfDocumentKind kind)

Parameters

package OdfPackage
kind OdfDocumentKind

InitializeMinimalPackage(OdfPackage, OdfDocumentKind, OdfVersion)

Populates the package with a minimal ODF entity of the specified document kind. 以指定的文件類型在封裝中填入最小的 ODF 實體。

public static void InitializeMinimalPackage(OdfPackage package, OdfDocumentKind kind, OdfVersion version)

Parameters

package OdfPackage

The OdfPackage instance to initialize. / 要初始化的 OdfPackage 執行個體。

kind OdfDocumentKind

The ODF document kind. / ODF 文件的類型。

version OdfVersion

The ODF specification version. / ODF 規格版本。

LoadDocument(Stream)

Loads a high-level ODF document wrapper from the specified stream. 從指定資料流載入高階 ODF 文件 wrapper。

public static OdfDocument LoadDocument(Stream stream)

Parameters

stream Stream

Returns

OdfDocument

The loaded ODF document. / 載入完成的 ODF 文件。

LoadDocument(Stream, OdfLoadOptions?)

Short overload of LoadDocument that accepts stream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 options;其餘可選參數使用預設值並轉呼叫最長 LoadDocument 多載。

public static OdfDocument LoadDocument(Stream stream, OdfLoadOptions? options)

Parameters

stream Stream
options OdfLoadOptions

Returns

OdfDocument

LoadDocument(Stream, OdfLoadOptions?, string?)

Loads a high-level ODF document wrapper from the specified stream and load options. 從指定資料流與載入選項載入高階 ODF 文件 wrapper。

public static OdfDocument LoadDocument(Stream stream, OdfLoadOptions? options, string? fileName)

Parameters

stream Stream

The stream containing the ODF document content. / 包含 ODF 文件內容的資料流。

options OdfLoadOptions

The load options, such as a password for encrypted documents and security limits. / 載入選項,例如加密文件密碼與安全限制。

fileName string

The optional file name, used to assist format detection. / 選用的檔案名稱,用於輔助格式偵測。

Returns

OdfDocument

The loaded ODF document. / 載入完成的 ODF 文件。

LoadDocument(Stream, string?)

Short overload of LoadDocument that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadDocument 多載。

public static OdfDocument LoadDocument(Stream stream, string? fileName)

Parameters

stream Stream
fileName string

Returns

OdfDocument

LoadDocument(string)

Loads a high-level ODF document wrapper from the specified path. 從指定路徑載入高階 ODF 文件 wrapper。

public static OdfDocument LoadDocument(string path)

Parameters

path string

The ODF document path. / ODF 文件路徑。

Returns

OdfDocument

The loaded ODF document. / 載入完成的 ODF 文件。

LoadDocument(string, OdfLoadOptions?)

Loads a high-level ODF document wrapper from the specified path and load options. 從指定路徑與載入選項載入高階 ODF 文件 wrapper。

public static OdfDocument LoadDocument(string path, OdfLoadOptions? options)

Parameters

path string

The ODF document path. / ODF 文件路徑。

options OdfLoadOptions

The load options, such as a password for encrypted documents and security limits. / 載入選項,例如加密文件密碼與安全限制。

Returns

OdfDocument

The loaded ODF document. / 載入完成的 ODF 文件。

LoadDocumentAsync(Stream)

Asynchronously loads a high-level ODF document wrapper from the specified stream. 非同步從指定資料流載入高階 ODF 文件 wrapper。

public static Task<OdfDocument> LoadDocumentAsync(Stream stream)

Parameters

stream Stream

Returns

Task<OdfDocument>

A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。

LoadDocumentAsync(Stream, OdfLoadOptions?)

Short overload of LoadDocumentAsync that accepts stream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 options;其餘可選參數使用預設值並轉呼叫最長 LoadDocumentAsync 多載。

public static Task<OdfDocument> LoadDocumentAsync(Stream stream, OdfLoadOptions? options)

Parameters

stream Stream
options OdfLoadOptions

Returns

Task<OdfDocument>

LoadDocumentAsync(Stream, OdfLoadOptions?, string?)

Short overload of LoadDocumentAsync that accepts stream, options, and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、options 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadDocumentAsync 多載。

public static Task<OdfDocument> LoadDocumentAsync(Stream stream, OdfLoadOptions? options, string? fileName)

Parameters

stream Stream
options OdfLoadOptions
fileName string

Returns

Task<OdfDocument>

LoadDocumentAsync(Stream, OdfLoadOptions?, string?, CancellationToken)

Asynchronously loads a high-level ODF document wrapper from the specified stream and load options. 非同步從指定資料流與載入選項載入高階 ODF 文件 wrapper。

public static Task<OdfDocument> LoadDocumentAsync(Stream stream, OdfLoadOptions? options, string? fileName, CancellationToken cancellationToken)

Parameters

stream Stream

The stream containing the ODF document content. / 包含 ODF 文件內容的資料流。

options OdfLoadOptions

The load options, such as a password for encrypted documents and security limits. / 載入選項,例如加密文件密碼與安全限制。

fileName string

The optional file name, used to assist format detection. / 選用的檔案名稱,用於輔助格式偵測。

cancellationToken CancellationToken

The cancellation token. / 取消語彙基元。

Returns

Task<OdfDocument>

A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。

LoadDocumentAsync(Stream, string?)

Short overload of LoadDocumentAsync that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadDocumentAsync 多載。

public static Task<OdfDocument> LoadDocumentAsync(Stream stream, string? fileName)

Parameters

stream Stream
fileName string

Returns

Task<OdfDocument>

LoadDocumentAsync(Stream, string?, CancellationToken)

Short overload of LoadDocumentAsync that accepts stream, fileName, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、fileName 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadDocumentAsync 多載。

public static Task<OdfDocument> LoadDocumentAsync(Stream stream, string? fileName, CancellationToken cancellationToken)

Parameters

stream Stream
fileName string
cancellationToken CancellationToken

Returns

Task<OdfDocument>

LoadDocumentAsync(string)

Asynchronously loads a high-level ODF document wrapper from the specified path. 非同步從指定路徑載入高階 ODF 文件 wrapper。

public static Task<OdfDocument> LoadDocumentAsync(string path)

Parameters

path string

Returns

Task<OdfDocument>

A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。

LoadDocumentAsync(string, OdfLoadOptions?)

Asynchronously loads a high-level ODF document wrapper from the specified path and load options. 非同步從指定路徑與載入選項載入高階 ODF 文件 wrapper。

public static Task<OdfDocument> LoadDocumentAsync(string path, OdfLoadOptions? options)

Parameters

path string
options OdfLoadOptions

Returns

Task<OdfDocument>

A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。

LoadDocumentAsync(string, OdfLoadOptions?, CancellationToken)

Short overload of LoadDocumentAsync that accepts path, options, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path、options 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadDocumentAsync 多載。

public static Task<OdfDocument> LoadDocumentAsync(string path, OdfLoadOptions? options, CancellationToken cancellationToken)

Parameters

path string
options OdfLoadOptions
cancellationToken CancellationToken

Returns

Task<OdfDocument>

LoadDocumentAsync(string, CancellationToken)

Short overload of LoadDocumentAsync that accepts path and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadDocumentAsync 多載。

public static Task<OdfDocument> LoadDocumentAsync(string path, CancellationToken cancellationToken)

Parameters

path string
cancellationToken CancellationToken

Returns

Task<OdfDocument>

WriteFlatXml(Stream, OdfDocumentKind)

Writes a minimal flat XML ODF document with default write options. 以預設寫入選項寫入最小 Flat XML ODF 文件。

public static void WriteFlatXml(Stream stream, OdfDocumentKind kind)

Parameters

stream Stream

The destination stream. / 目的串流。

kind OdfDocumentKind

The ODF document kind. / ODF 文件種類。

WriteFlatXml(Stream, OdfDocumentKind, OdfFlatXmlWriteOptions)

Writes a minimal flat XML ODF document using write options. 以寫入選項寫入最小 Flat XML ODF 文件。

public static void WriteFlatXml(Stream stream, OdfDocumentKind kind, OdfFlatXmlWriteOptions options)

Parameters

stream Stream

The destination stream. / 目的串流。

kind OdfDocumentKind

The ODF document kind. / ODF 文件種類。

options OdfFlatXmlWriteOptions

The flat XML write options. / Flat XML 寫入選項。