Class OdfDocument
Wires shared collaborators used by core document persistence operations. 串接核心文件持久化作業使用的共用協作者。
public abstract class OdfDocument : IDisposable, IAsyncDisposable
- Inheritance
-
OdfDocument
- Implements
- Derived
- Inherited Members
Constructors
OdfDocument(OdfPackage)
Initializes a new instance of the OdfDocument class. 初始化 OdfDocument 類別的新執行個體。
protected OdfDocument(OdfPackage package)
Parameters
packageOdfPackageThe OdfPackage container. / OdfPackage 封裝容器。
OdfDocument(OdfPackage, string)
Initializes a new instance of the OdfDocument class with the specified sub-path. 初始化指定子路徑的 OdfDocument 類別的新執行個體。
protected OdfDocument(OdfPackage package, string subPath)
Parameters
packageOdfPackageThe OdfPackage container. / OdfPackage 封裝容器。
subPathstringThe sub-path of the embedded document within the package. / 嵌入式文件在封裝中的子路徑。
Properties
AutoCalculate
Gets or sets a value indicating whether spreadsheet formulas are recalculated automatically. 取得或設定是否自動重新計算試算表公式。
public bool AutoCalculate { get; set; }
Property Value
Bookmarks
Gets the bookmark manager, providing a high-level interface for safely reading, writing, and manipulating bookmarks. 取得書籤管理器,提供安全讀寫與操作書籤的高階介面。
public OdfBookmarkManager Bookmarks { get; }
Property Value
- OdfBookmarkManager
ContentKind
Gets the content kind used by the current document under office:body.
取得目前文件在 office:body 下使用的內容種類。
public OdfDocumentKind ContentKind { get; }
Property Value
CreationDate
Gets or sets the document creation timestamp. 取得或設定文件建立日期。
public DateTime? CreationDate { get; set; }
Property Value
Creator
Gets or sets the document creator. 取得或設定文件建立者。
public string? Creator { get; set; }
Property Value
Description
Gets or sets the document description. 取得或設定文件描述。
public string? Description { get; set; }
Property Value
DocumentKind
Gets the ODF document kind declared by the current package's MIME type. 取得目前封裝 MIME 類型所宣告的 ODF 文件種類。
public OdfDocumentKind DocumentKind { get; }
Property Value
Format
Gets the format description corresponding to the current document kind; null if the MIME type is not recognized. 取得目前文件種類對應的格式描述;若 MIME 類型無法辨識則為 null。
public OdfFormatInfo? Format { get; }
Property Value
IsFlatXml
Gets a value indicating whether the current document is a single-file (Flat XML) ODF format. 取得一個值,指出目前文件是否為單一 XML (Flat XML) ODF 格式。
public bool IsFlatXml { get; }
Property Value
IsMasterDocument
Gets a value indicating whether the current document is an ODF master document format. 取得一個值,指出目前文件是否為 ODF 主控文件格式。
public bool IsMasterDocument { get; }
Property Value
IsTemplate
Gets a value indicating whether the current document is an ODF template format. 取得一個值,指出目前文件是否為 ODF 範本格式。
public bool IsTemplate { get; }
Property Value
IsUpdateActive
Provides the IsUpdateActive member. 取得目前文件是否位於批次更新範圍內。
public bool IsUpdateActive { get; }
Property Value
Language
Gets or sets the document language tag. 取得或設定文件語言。
public string? Language { get; set; }
Property Value
LinkUpdateMode
Gets or sets the external link update mode stored in document settings. 取得或設定文件設定中儲存的外部連結更新模式。
public int LinkUpdateMode { get; set; }
Property Value
ModificationDate
Gets or sets the document modification timestamp. 取得或設定文件修改日期。
public DateTime? ModificationDate { get; set; }
Property Value
Package
Gets the ODF package container associated with this document. 取得與此文件相關聯的 ODF 封裝容器。
public OdfPackage Package { get; }
Property Value
Styles
Gets the document's style engine, usable for style property lookup, deduplication, and unused style reclamation. 取得文件樣式引擎,可用於樣式屬性查詢、去重與未使用樣式回收。
public OdfStyleEngine Styles { get; }
Property Value
SubPath
Gets or sets the path of an embedded document within the package container. Empty for a root document. 取得或設定嵌入式文件在封裝容器內的路徑。若為根文件則為空字串。
public string SubPath { get; set; }
Property Value
Subject
Gets or sets the document subject. 取得或設定文件主旨。
public string? Subject { get; set; }
Property Value
TargetVersion
Gets or sets the ODF version to declare when the document is saved. 取得或設定文件儲存時要宣告的目標 ODF 版本。
public OdfVersion? TargetVersion { get; set; }
Property Value
TemplateMetadata
Gets or sets metadata describing the source template. 取得或設定文件來源範本中繼資料。
public OdfTemplateMetadata? TemplateMetadata { get; set; }
Property Value
Title
Gets or sets the document title. 取得或設定文件標題。
public string? Title { get; set; }
Property Value
ZoomLevel
Gets or sets the document view zoom percentage. 取得或設定文件檢視縮放百分比。
public double ZoomLevel { get; set; }
Property Value
Methods
AddMasterPage(string)
Adds master page. 新增一個指定名稱的主控頁面(Master Page)。
public OdfMasterPage AddMasterPage(string name)
Parameters
namestring主控頁面的名稱
Returns
- OdfMasterPage
新增的主控頁面執行個體
AdoptNode(OdfDocument, OdfNode)
Performs adopt node. 採納來源文件中的節點至目前文件,將其與原父節點脫鉤,並轉移其所有權至目前文件。
public virtual OdfNode AdoptNode(OdfDocument sourceDocument, OdfNode node)
Parameters
sourceDocumentOdfDocument來源文件
nodeOdfNode要採納的來源節點
Returns
- OdfNode
已完成採納的節點實體(與原 Parent 脫鉤,且 Document 屬性已更新)
Remarks
此方法實作了 O(1) 零拷貝節點轉移。來源文件資訊用於跨文件媒體參照移轉,避免嵌入圖片或物件在採納後失聯。
AdoptNode(OdfNode)
Performs adopt node. 採納來源節點至目前文件,將其與原父節點脫鉤,並轉移其所有權至目前文件。
public virtual OdfNode AdoptNode(OdfNode node)
Parameters
nodeOdfNode要採納的來源節點
Returns
- OdfNode
已完成採納的節點實體(與原 Parent 脫鉤,且 Document 屬性已更新)
Remarks
此方法實作了 O(1) 零拷貝節點轉移。當來源節點來自另一份文件時, 會自動處理必要的媒體參照移轉與命名空間補全。
AppendDocument(OdfDocument)
Short overload of AppendDocument that accepts otherDoc; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 otherDoc;其餘可選參數使用預設值並轉呼叫最長 AppendDocument 多載。
public virtual void AppendDocument(OdfDocument otherDoc)
Parameters
otherDocOdfDocument
AppendDocument(OdfDocument, OdfMergeOptions?)
Appends document. 將另一份 ODF 文件附加到目前文件。
public virtual void AppendDocument(OdfDocument otherDoc, OdfMergeOptions? options)
Parameters
otherDocOdfDocument要附加的來源文件
optionsOdfMergeOptions合併選項
BeginUpdate()
Performs begin update. 開始批次更新範圍,暫緩樣式重對照與自動樣式去重,直到最外層範圍結束。
public IDisposable BeginUpdate()
Returns
- IDisposable
可釋放的批次更新範圍;建議搭配
using使用
Remarks
批次更新範圍支援巢狀呼叫。只有最外層 EndUpdate() 或範圍釋放時,才會重新整理延後的樣式變更。
ClearParagraphTextContentRecursive(OdfNode)
Clears paragraph text content recursive.
遞迴清除指定節點底下所有 text:p/text:span 段落的文字內容,但保留節點結構
protected static void ClearParagraphTextContentRecursive(OdfNode node)
Parameters
nodeOdfNode要清除文字內容的根節點
ClearTemplateUserContent()
Clears template user content. 清除範本實例化後的使用者內容,但保留格式與版面配置。
protected virtual void ClearTemplateUserContent()
Remarks
基底實作不做任何事;各文件種類(文字、試算表、簡報、繪圖)於對應的部分類別中覆寫, 依各自的內容模型清除使用者資料。
ConvertFlatXmlToZip(string, string)
Short overload of ConvertFlatXmlToZip that accepts sourcePath and destinationPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sourcePath 與 destinationPath;其餘可選參數使用預設值並轉呼叫最長 ConvertFlatXmlToZip 多載。
public static void ConvertFlatXmlToZip(string sourcePath, string destinationPath)
Parameters
ConvertFlatXmlToZip(string, string, OdfLoadOptions?)
Short overload of ConvertFlatXmlToZip that accepts sourcePath, destinationPath, and loadOptions; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sourcePath、destinationPath 與 loadOptions;其餘可選參數使用預設值並轉呼叫最長 ConvertFlatXmlToZip 多載。
public static void ConvertFlatXmlToZip(string sourcePath, string destinationPath, OdfLoadOptions? loadOptions)
Parameters
sourcePathstringdestinationPathstringloadOptionsOdfLoadOptions
ConvertFlatXmlToZip(string, string, OdfLoadOptions?, OdfSaveOptions?)
Converts flat xml to zip. 將 Flat XML 格式的 ODF 文件就地轉換為一般 ZIP 封裝格式。
public static void ConvertFlatXmlToZip(string sourcePath, string destinationPath, OdfLoadOptions? loadOptions, OdfSaveOptions? saveOptions)
Parameters
sourcePathstring來源 Flat XML 文件路徑
destinationPathstring目標 ZIP 封裝文件路徑
loadOptionsOdfLoadOptions載入選項;若為 null,則使用預設選項
saveOptionsOdfSaveOptions儲存設定選項;若為 null,則使用預設選項
ConvertZipToFlatXml(string, string)
Short overload of ConvertZipToFlatXml that accepts sourcePath and destinationPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sourcePath 與 destinationPath;其餘可選參數使用預設值並轉呼叫最長 ConvertZipToFlatXml 多載。
public static void ConvertZipToFlatXml(string sourcePath, string destinationPath)
Parameters
ConvertZipToFlatXml(string, string, OdfLoadOptions?)
Short overload of ConvertZipToFlatXml that accepts sourcePath, destinationPath, and loadOptions; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sourcePath、destinationPath 與 loadOptions;其餘可選參數使用預設值並轉呼叫最長 ConvertZipToFlatXml 多載。
public static void ConvertZipToFlatXml(string sourcePath, string destinationPath, OdfLoadOptions? loadOptions)
Parameters
sourcePathstringdestinationPathstringloadOptionsOdfLoadOptions
ConvertZipToFlatXml(string, string, OdfLoadOptions?, OdfSaveOptions?)
Converts zip to flat xml. 將一般 ZIP 封裝的 ODF 文件就地轉換為 Flat XML 格式。
public static void ConvertZipToFlatXml(string sourcePath, string destinationPath, OdfLoadOptions? loadOptions, OdfSaveOptions? saveOptions)
Parameters
sourcePathstring來源 ZIP 封裝文件路徑
destinationPathstring目標 Flat XML 文件路徑
loadOptionsOdfLoadOptions載入選項;若為 null,則使用預設選項
saveOptionsOdfSaveOptions儲存設定選項;若為 null,則使用預設選項
Create(OdfDocumentKind)
Creates an ODF document of the specified kind. 建立指定種類的 ODF 文件。
public static OdfDocument Create(OdfDocumentKind kind)
Parameters
kindOdfDocumentKindThe ODF document kind to create. / 要建立的 ODF 文件種類。
Returns
- OdfDocument
The created ODF document. / 建立完成的 ODF 文件。
CreateEmbeddedDocument<T>(string)
Creates a new embedded ODF document at the specified package subpath. 在指定封裝子路徑建立新的嵌入式 ODF 文件。
public T CreateEmbeddedDocument<T>(string subPath) where T : OdfDocument
Parameters
subPathstringThe package subpath where the embedded document is created. / 建立嵌入式文件的封裝子路徑。
Returns
- T
The created embedded document wrapper. / 建立完成的嵌入式文件包裝器。
Type Parameters
TThe embedded document wrapper type. / 嵌入式文件包裝器型別。
Remarks
此方法會在建立時立即呼叫一次傳回文件的 Save() 以寫入最小骨架內容;
後續透過傳回 wrapper 所做的修改會由父文件 Save(OdfSaveOptions?)、
SaveToStream(Stream, OdfSaveOptions?) 與非同步儲存流程自動 flush 至封裝。
呼叫端仍可手動呼叫嵌入式文件的 Save() 以提早寫回。
Dispose()
Releases the document and underlying package resources. 釋放文件與底層封裝資源。
public void Dispose()
Dispose(bool)
Releases the resources held by the document. 釋放文件持有的資源。
protected virtual void Dispose(bool disposing)
Parameters
DisposeAsync()
Asynchronously releases the document and underlying package resources. 非同步釋放文件與底層封裝資源。
public ValueTask DisposeAsync()
Returns
- ValueTask
A value task representing the asynchronous release operation. / 代表非同步釋放作業的值工作。
EndUpdate()
Performs end update. 結束目前批次更新範圍,並在離開最外層範圍時重新整理延後的樣式變更。
public void EndUpdate()
Exceptions
- InvalidOperationException
當未先呼叫 BeginUpdate() 時擲出
ExportToPdf(Stream)
Short overload of ExportToPdf that accepts pdfStream; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 pdfStream;其餘可選參數使用預設值並轉呼叫最長 ExportToPdf 多載。
public void ExportToPdf(Stream pdfStream)
Parameters
pdfStreamStream
ExportToPdf(Stream, X509Certificate2?)
Converts and exports the current document to PDF format. 將目前文件轉換並匯出為 PDF 格式。
public void ExportToPdf(Stream pdfStream, X509Certificate2? certificate)
Parameters
pdfStreamStreamThe target stream to which the PDF is written. / 要寫入 PDF 的目標資料流。
certificateX509Certificate2The certificate used to sign the PDF; if null, the PDF is not signed. / 用於簽章 PDF 的憑證;若為 null 則不簽章。
FindCustomProperty(string)
Finds the custom metadata property. 尋找自訂中繼資料屬性。
public object? FindCustomProperty(string name)
Parameters
namestringThe custom property name. / 自訂屬性名稱。
Returns
FindCustomProperty<T>(string)
Finds and converts the custom metadata property to the specified type. 尋找自訂中繼資料屬性,並轉換成指定型別。
public T? FindCustomProperty<T>(string name)
Parameters
namestringThe custom property name. / 自訂屬性名稱。
Returns
- T
The converted property value, or the default value when missing or conversion fails. / 轉換後的屬性值;若不存在或轉換失敗則為預設值。
Type Parameters
TThe target value type. / 目標值型別。
FindOrCreateChild(OdfNode, string, string, string)
Finds or create child. 尋找或建立指定子元素。
protected OdfNode FindOrCreateChild(OdfNode parent, string localName, string ns, string prefix)
Parameters
Returns
- OdfNode
符合條件的既有或新建子元素
FindOrCreateConfigItemNode(OdfNode, string, string)
Finds or create config item node. 尋找或建立設定專案節點。
protected OdfNode FindOrCreateConfigItemNode(OdfNode entryNode, string name, string type)
Parameters
Returns
- OdfNode
設定專案節點
FindOrCreateMapEntryNode(OdfNode)
Finds or create map entry node. 尋找或建立設定 map entry 節點。
protected OdfNode FindOrCreateMapEntryNode(OdfNode mapNode)
Parameters
mapNodeOdfNode設定 map 節點
Returns
- OdfNode
設定 map entry 節點
FindOrCreateMapNode(OdfNode, string)
Finds or create map node. 尋找或建立設定 map 節點。
protected OdfNode FindOrCreateMapNode(OdfNode setNode, string name)
Parameters
setNodeOdfNode設定集合節點
namestringmap 名稱
Returns
- OdfNode
設定 map 節點
FindOrCreateMetaRoot()
Finds or create meta root. 尋找或建立 office:meta 根節點。
protected OdfNode FindOrCreateMetaRoot()
Returns
- OdfNode
office:meta 節點
FindOrCreateSettingsNode(OdfNode, string)
Finds or create settings node. 尋找或建立指定名稱的設定集合節點。
protected OdfNode FindOrCreateSettingsNode(OdfNode root, string name)
Parameters
rootOdfNode設定 DOM 根節點
namestring設定集合名稱
Returns
- OdfNode
設定集合節點
FindSettingsConfigItem(string)
Finds settings config item. 尋找指定名稱的設定專案。
protected OdfNode? FindSettingsConfigItem(string name)
Parameters
namestring設定專案名稱
Returns
- OdfNode
設定專案節點;若不存在則為 null
FindSettingsNode(OdfNode, string)
Finds settings node. 尋找指定名稱的設定集合節點。
protected OdfNode? FindSettingsNode(OdfNode root, string name)
Parameters
rootOdfNode設定 DOM 根節點
namestring設定集合名稱
Returns
- OdfNode
設定集合節點;若不存在則為 null
GetAllCustomProperties()
Gets all custom metadata properties. 取得所有自訂中繼資料屬性的字典。
public IReadOnlyDictionary<string, object?> GetAllCustomProperties()
Returns
- IReadOnlyDictionary<string, object>
A read-only dictionary keyed by property name. / 以屬性名稱為鍵的唯讀字典。
GetDefaultContentXml()
Gets the default content.xml for this document kind. 取得此文件類型的預設 content.xml。
protected abstract string GetDefaultContentXml()
Returns
- string
The default content.xml string. / 預設 content.xml 字串。
GetDefaultMetaXml()
Gets the default meta.xml for this document kind. 取得此文件類型的預設 meta.xml。
protected virtual string GetDefaultMetaXml()
Returns
- string
The default meta.xml string. / 預設 meta.xml 字串。
GetDefaultSettingsXml()
Gets the default settings.xml for this document kind. 取得此文件類型的預設 settings.xml。
protected virtual string GetDefaultSettingsXml()
Returns
- string
The default settings.xml string. / 預設 settings.xml 字串。
GetDefaultStylesXml()
Gets the default styles.xml for this document kind. 取得此文件類型的預設 styles.xml。
protected abstract string GetDefaultStylesXml()
Returns
- string
The default styles.xml string. / 預設 styles.xml 字串。
GetEmbeddedDocument<T>(string)
Gets an embedded ODF document wrapper for the specified package subpath. 取得指定封裝子路徑的嵌入式 ODF 文件包裝器。
public T GetEmbeddedDocument<T>(string subPath) where T : OdfDocument
Parameters
subPathstringThe package subpath that contains the embedded document. / 包含嵌入式文件的封裝子路徑。
Returns
- T
The embedded document wrapper. / 嵌入式文件包裝器。
Type Parameters
TThe embedded document wrapper type. / 嵌入式文件包裝器型別。
GetMasterPages()
Gets master pages. 取得文件中所有的主控頁面(Master Page)。
public IEnumerable<OdfMasterPage> GetMasterPages()
Returns
- IEnumerable<OdfMasterPage>
主控頁面集合
GetSignatureSummary()
Gets signature summary. 取得文件封裝內數位簽章專案的摘要狀態。
public OdfDocumentSignatureSummary GetSignatureSummary()
Returns
- OdfDocumentSignatureSummary
描述簽章專案存在狀態、可讀性與簽章數量的摘要
Load(Stream)
Loads an ODF document from the specified stream. 從指定資料流載入 ODF 文件。
public static OdfDocument Load(Stream stream)
Parameters
streamStream
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
Load(Stream, OdfLoadOptions?)
Loads an ODF document from the specified stream and load options. 從指定資料流與載入選項載入 ODF 文件。
public static OdfDocument Load(Stream stream, OdfLoadOptions? options)
Parameters
streamStreamoptionsOdfLoadOptions
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
Load(Stream, OdfLoadOptions?, string?)
Short overload of Load that accepts stream, options, and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、options 與 fileName;其餘可選參數使用預設值並轉呼叫最長 Load 多載。
public static OdfDocument Load(Stream stream, OdfLoadOptions? options, string? fileName)
Parameters
streamStreamoptionsOdfLoadOptionsfileNamestring
Returns
Load(Stream, string?)
Short overload of Load that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 Load 多載。
public static OdfDocument Load(Stream stream, string? fileName)
Parameters
Returns
Load(string)
Loads an ODF document from the specified path. 從指定路徑載入 ODF 文件。
public static OdfDocument Load(string path)
Parameters
pathstringThe ODF document path. / ODF 文件路徑。
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
Remarks
在 ASP.NET Core 等伺服器環境中,請優先使用 LoadAsync(string, CancellationToken) 以避免阻塞執行緒
Load(string, OdfLoadOptions?)
Loads an ODF document from the specified path and load options. 從指定路徑與載入選項載入 ODF 文件。
public static OdfDocument Load(string path, OdfLoadOptions? options)
Parameters
pathstringThe ODF document path. / ODF 文件路徑。
optionsOdfLoadOptionsThe load options, such as a password for encrypted documents and security limits. / 載入選項,例如加密文件密碼與安全限制。
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
LoadAsync(Stream)
Asynchronously loads an ODF document from the specified stream. 非同步從指定資料流載入 ODF 文件。
public static Task<OdfDocument> LoadAsync(Stream stream)
Parameters
streamStream
Returns
- Task<OdfDocument>
A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與封裝初始化期間協作檢查取消語彙。
LoadAsync(Stream, OdfLoadOptions?)
Asynchronously loads an ODF document from the specified stream and load options. 非同步從指定資料流與載入選項載入 ODF 文件。
public static Task<OdfDocument> LoadAsync(Stream stream, OdfLoadOptions? options)
Parameters
streamStreamoptionsOdfLoadOptions
Returns
- Task<OdfDocument>
A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。
LoadAsync(Stream, OdfLoadOptions?, string?)
Short overload of LoadAsync that accepts stream, options, and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、options 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<OdfDocument> LoadAsync(Stream stream, OdfLoadOptions? options, string? fileName)
Parameters
streamStreamoptionsOdfLoadOptionsfileNamestring
Returns
LoadAsync(Stream, OdfLoadOptions?, string?, CancellationToken)
Short overload of LoadAsync that accepts stream, options, fileName, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、options、fileName 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<OdfDocument> LoadAsync(Stream stream, OdfLoadOptions? options, string? fileName, CancellationToken cancellationToken)
Parameters
streamStreamoptionsOdfLoadOptionsfileNamestringcancellationTokenCancellationToken
Returns
LoadAsync(Stream, string?)
Short overload of LoadAsync that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<OdfDocument> LoadAsync(Stream stream, string? fileName)
Parameters
Returns
LoadAsync(Stream, string?, CancellationToken)
Short overload of LoadAsync that accepts stream, fileName, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、fileName 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<OdfDocument> LoadAsync(Stream stream, string? fileName, CancellationToken cancellationToken)
Parameters
streamStreamfileNamestringcancellationTokenCancellationToken
Returns
LoadAsync(Stream, CancellationToken)
Asynchronously loads an ODF document from a stream with a cancellation token. 以取消語彙基元非同步從資料流載入 ODF 文件。
public static Task<OdfDocument> LoadAsync(Stream stream, CancellationToken cancellationToken)
Parameters
streamStreamThe document stream. / 文件資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfDocument>
A task whose result is the loaded document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。
LoadAsync(string)
Asynchronously loads an ODF document from the specified path. 非同步從指定路徑載入 ODF 文件。
public static Task<OdfDocument> LoadAsync(string path)
Parameters
pathstring
Returns
- Task<OdfDocument>
A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與封裝初始化期間協作檢查取消語彙。
LoadAsync(string, OdfLoadOptions?)
Asynchronously loads an ODF document from the specified path and load options. 非同步從指定路徑與載入選項載入 ODF 文件。
public static Task<OdfDocument> LoadAsync(string path, OdfLoadOptions? options)
Parameters
pathstringoptionsOdfLoadOptions
Returns
- Task<OdfDocument>
A task representing the asynchronous load operation, whose result is the loaded ODF document. / 代表非同步載入作業的工作,其結果為載入完成的 ODF 文件。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與封裝初始化期間協作檢查取消語彙。
LoadAsync(string, OdfLoadOptions?, CancellationToken)
Short overload of LoadAsync that accepts path, options, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path、options 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<OdfDocument> LoadAsync(string path, OdfLoadOptions? options, CancellationToken cancellationToken)
Parameters
pathstringoptionsOdfLoadOptionscancellationTokenCancellationToken
Returns
LoadAsync(string, CancellationToken)
Short overload of LoadAsync that accepts path and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<OdfDocument> LoadAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringcancellationTokenCancellationToken
Returns
LoadEncryptedAsync(Stream, string, string?, CancellationToken)
Asynchronously loads and decrypts an ODF document from the specified stream. 非同步從指定資料流載入並解密 ODF 文件。
public static Task<OdfDocument> LoadEncryptedAsync(Stream stream, string password, string? fileName, CancellationToken cancellationToken)
Parameters
streamStreamThe stream containing the ODF document. / 包含 ODF 文件的資料流。
passwordstringThe password used to decrypt the document. / 用於解密文件的密碼。
fileNamestringThe optional file name used to assist format detection. / 用於輔助格式偵測的選用檔案名稱。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfDocument>
A task whose result is the decrypted document. / 工作結果為已解密文件。
LoadEncryptedAsync(string, string, CancellationToken)
Asynchronously loads and decrypts an ODF document from the specified path. 非同步從指定路徑載入並解密 ODF 文件。
public static Task<OdfDocument> LoadEncryptedAsync(string path, string password, CancellationToken cancellationToken)
Parameters
pathstringThe ODF document path. / ODF 文件路徑。
passwordstringThe password used to decrypt the document. / 用於解密文件的密碼。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfDocument>
A task whose result is the decrypted document. / 工作結果為已解密文件。
LoadFromFlatXml(Stream)
Loads an ODF document from the specified Flat XML stream. 從指定的 Flat XML 資料流載入 ODF 文件。
public static OdfDocument LoadFromFlatXml(Stream stream)
Parameters
streamStreamThe Flat XML stream. / Flat XML 資料流。
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
LoadFromFlatXml(Stream, OdfLoadOptions?)
Loads an ODF document from the specified Flat XML stream and load options. 從指定的 Flat XML 資料流與載入選項載入 ODF 文件。
public static OdfDocument LoadFromFlatXml(Stream stream, OdfLoadOptions? options)
Parameters
streamStreamThe Flat XML stream. / Flat XML 資料流。
optionsOdfLoadOptionsThe load options; when null, defaults are used. / 載入選項;若為 null,則使用預設選項。
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
LoadFromFlatXml(string)
Loads an ODF document from the specified Flat XML file path. 從指定的 Flat XML 檔案載入 ODF 文件。
public static OdfDocument LoadFromFlatXml(string path)
Parameters
pathstringThe Flat XML file path. / Flat XML 檔案路徑。
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
LoadFromFlatXml(string, OdfLoadOptions?)
Loads an ODF document from the specified Flat XML file path and load options. 從指定的 Flat XML 檔案與載入選項載入 ODF 文件。
public static OdfDocument LoadFromFlatXml(string path, OdfLoadOptions? options)
Parameters
pathstringThe Flat XML file path. / Flat XML 檔案路徑。
optionsOdfLoadOptionsThe load options; when null, defaults are used. / 載入選項;若為 null,則使用預設選項。
Returns
- OdfDocument
The loaded ODF document. / 載入完成的 ODF 文件。
MergeContentNodes(OdfDocument, OdfMergeOptions, Dictionary<string, string>)
Merges content nodes. 將來源文件的內容節點合併到目前文件。
protected abstract void MergeContentNodes(OdfDocument sourceDoc, OdfMergeOptions options, Dictionary<string, string> renameMap)
Parameters
sourceDocOdfDocument來源文件
optionsOdfMergeOptions合併選項
renameMapDictionary<string, string>樣式重新命名對照表
RemapStylesInNodes(OdfNode, Dictionary<string, string>)
Performs remap styles in nodes. 依樣式重新命名對照表重寫節點樹中的樣式參照。
protected void RemapStylesInNodes(OdfNode node, Dictionary<string, string> renameMap)
Parameters
nodeOdfNode要處理的根節點
renameMapDictionary<string, string>樣式重新命名對照表
ReplaceText(string, string)
Searches the entire document's DOM tree for the specified text and replaces it with new text, preserving the text's formatting and style structure. 在整份文件的 DOM 樹中搜尋指定文字並替換為新文字,同時保留文字的格式與樣式結構。
public virtual void ReplaceText(string search, string replacement)
Parameters
searchstringThe keyword to search for. / 要搜尋的關鍵字。
replacementstringThe new text to replace it with. / 要替換的新文字。
SanitizeMacros()
Sanitizes the document, removing all VBA and StarBasic macro scripts, digital signatures, and script references. 清理文件,移除所有 VBA 與 StarBasic 巨集指令碼、數位簽章及指令碼參照。
public void SanitizeMacros()
Save()
Saves the document back to its package container. 將文件儲存回其 ODF 封裝容器。
public virtual void Save()
Remarks
Prefer SaveAsync(OdfSaveOptions?, CancellationToken) in server environments to avoid blocking request threads. 在 ASP.NET Core 等伺服器環境中,請優先使用 SaveAsync(OdfSaveOptions?, CancellationToken) 以避免阻塞要求執行緒。
Save(OdfSaveOptions?)
Full overload of Save that accepts options. Save 完整多載:接受 options。
public virtual void Save(OdfSaveOptions? options)
Parameters
optionsOdfSaveOptions
Save(string)
Saves the document to the specified file path. 將文件儲存至指定檔案路徑。
public void Save(string path)
Parameters
pathstring
Save(string, OdfSaveOptions?)
Full overload of Save that accepts path and options. Save 完整多載:接受 path 與 options。
public void Save(string path, OdfSaveOptions? options)
Parameters
pathstringoptionsOdfSaveOptions
SaveAsFlatXml(Stream)
Saves as flat xml. 將文件儲存為單一 Flat XML 格式並寫入指定的資料流。
public void SaveAsFlatXml(Stream stream)
Parameters
streamStream
SaveAsFlatXml(Stream, OdfSaveOptions?)
Full overload of SaveAsFlatXml that accepts stream and options. SaveAsFlatXml 完整多載:接受 stream 與 options。
public void SaveAsFlatXml(Stream stream, OdfSaveOptions? options)
Parameters
streamStreamoptionsOdfSaveOptions
SaveAsFlatXml(string)
Saves as flat xml. 將文件儲存為單一 Flat XML 格式的檔案。
public void SaveAsFlatXml(string path)
Parameters
pathstring
SaveAsFlatXml(string, OdfSaveOptions?)
Full overload of SaveAsFlatXml that accepts path and options. SaveAsFlatXml 完整多載:接受 path 與 options。
public void SaveAsFlatXml(string path, OdfSaveOptions? options)
Parameters
pathstringoptionsOdfSaveOptions
SaveAsync()
Saves async. 非同步儲存文件至 ODF 封裝容器中。
public virtual Task SaveAsync()
Returns
- Task
代表非同步作業的 Task 執行個體
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 寫入與串流 I/O 期間協作檢查取消語彙。
SaveAsync(OdfSaveOptions?)
Short overload of SaveAsync that accepts options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 options;其餘可選參數使用預設值並轉呼叫最長 SaveAsync 多載。
public virtual Task SaveAsync(OdfSaveOptions? options)
Parameters
optionsOdfSaveOptions
Returns
SaveAsync(OdfSaveOptions?, CancellationToken)
Full overload of SaveAsync that accepts options and cancellationToken. SaveAsync 完整多載:接受 options 與 cancellationToken。
public virtual Task SaveAsync(OdfSaveOptions? options, CancellationToken cancellationToken)
Parameters
optionsOdfSaveOptionscancellationTokenCancellationToken
Returns
SaveAsync(Stream)
Saves async. 非同步將文件儲存至指定的資料流。
public Task SaveAsync(Stream destinationStream)
Parameters
destinationStreamStream
Returns
- Task
代表非同步儲存作業的工作
SaveAsync(Stream, OdfSaveOptions?)
Short overload of SaveAsync that accepts destinationStream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 destinationStream 與 options;其餘可選參數使用預設值並轉呼叫最長 SaveAsync 多載。
public Task SaveAsync(Stream destinationStream, OdfSaveOptions? options)
Parameters
destinationStreamStreamoptionsOdfSaveOptions
Returns
SaveAsync(Stream, OdfSaveOptions?, CancellationToken)
Short overload of SaveAsync that accepts destinationStream, options, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 destinationStream、options 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 SaveAsync 多載。
public Task SaveAsync(Stream destinationStream, OdfSaveOptions? options, CancellationToken cancellationToken)
Parameters
destinationStreamStreamoptionsOdfSaveOptionscancellationTokenCancellationToken
Returns
SaveAsync(Stream, CancellationToken)
Asynchronously saves the document to the specified stream with a cancellation token. 以取消語彙基元非同步將文件儲存至指定資料流。
public Task SaveAsync(Stream destinationStream, CancellationToken cancellationToken)
Parameters
destinationStreamStreamThe destination stream. / 目標資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveAsync(string)
Saves async. 非同步將文件儲存至指定檔案路徑。
public Task SaveAsync(string path)
Parameters
pathstring
Returns
- Task
代表非同步儲存作業的工作
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 寫入與檔案 I/O 期間協作檢查取消語彙。
SaveAsync(string, OdfSaveOptions?)
Short overload of SaveAsync that accepts path and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 options;其餘可選參數使用預設值並轉呼叫最長 SaveAsync 多載。
public Task SaveAsync(string path, OdfSaveOptions? options)
Parameters
pathstringoptionsOdfSaveOptions
Returns
SaveAsync(string, OdfSaveOptions?, CancellationToken)
Full overload of SaveAsync that accepts path, options, and cancellationToken. SaveAsync 完整多載:接受 path、options 與 cancellationToken。
public Task SaveAsync(string path, OdfSaveOptions? options, CancellationToken cancellationToken)
Parameters
pathstringoptionsOdfSaveOptionscancellationTokenCancellationToken
Returns
SaveAsync(string, CancellationToken)
Asynchronously saves the document to the specified path with a cancellation token. 以取消語彙基元非同步將文件儲存至指定路徑。
public Task SaveAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringThe destination file path. / 目標檔案路徑。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveEncryptedAsync(Stream, string, OdfEncryptionAlgorithm, CancellationToken)
Asynchronously saves the document to the specified stream with password encryption. 非同步以密碼加密並將文件儲存至指定資料流。
public Task SaveEncryptedAsync(Stream destinationStream, string password, OdfEncryptionAlgorithm algorithm, CancellationToken cancellationToken)
Parameters
destinationStreamStreamThe destination stream. / 目的地資料流。
passwordstringThe password used to encrypt the document. / 用於加密文件的密碼。
algorithmOdfEncryptionAlgorithmThe encryption algorithm to use. / 要使用的加密演算法。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveEncryptedAsync(string, OdfEncryptionAlgorithm, CancellationToken)
Asynchronously saves the document to its original destination with password encryption. 非同步以密碼加密並將文件儲存至原始目的地。
public Task SaveEncryptedAsync(string password, OdfEncryptionAlgorithm algorithm, CancellationToken cancellationToken)
Parameters
passwordstringThe password used to encrypt the document. / 用於加密文件的密碼。
algorithmOdfEncryptionAlgorithmThe encryption algorithm to use. / 要使用的加密演算法。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveEncryptedAsync(string, string, OdfEncryptionAlgorithm, CancellationToken)
Asynchronously saves the document to the specified path with password encryption. 非同步以密碼加密並將文件儲存至指定路徑。
public Task SaveEncryptedAsync(string path, string password, OdfEncryptionAlgorithm algorithm, CancellationToken cancellationToken)
Parameters
pathstringThe destination file path. / 目的地檔案路徑。
passwordstringThe password used to encrypt the document. / 用於加密文件的密碼。
algorithmOdfEncryptionAlgorithmThe encryption algorithm to use. / 要使用的加密演算法。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveToBytes()
Saves to bytes. 將文件儲存為 ODF 封裝位元組陣列。
public byte[] SaveToBytes()
Returns
- byte[]
包含文件封裝內容的位元組陣列
SaveToStream(Stream)
Saves to stream. 將文件儲存至指定的資料流。
public void SaveToStream(Stream destinationStream)
Parameters
destinationStreamStream
SaveToStream(Stream, OdfSaveOptions?)
Full overload of SaveToStream that accepts destinationStream and options. SaveToStream 完整多載:接受 destinationStream 與 options。
public void SaveToStream(Stream destinationStream, OdfSaveOptions? options)
Parameters
destinationStreamStreamoptionsOdfSaveOptions
SaveToStreamAsync(Stream)
Saves to stream async. 非同步將文件儲存至指定的資料流。
public Task SaveToStreamAsync(Stream destinationStream)
Parameters
destinationStreamStream
Returns
- Task
代表非同步儲存作業的工作
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 寫入與串流 I/O 期間協作檢查取消語彙。
SaveToStreamAsync(Stream, OdfSaveOptions?)
Short overload of SaveToStreamAsync that accepts destinationStream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 destinationStream 與 options;其餘可選參數使用預設值並轉呼叫最長 SaveToStreamAsync 多載。
public Task SaveToStreamAsync(Stream destinationStream, OdfSaveOptions? options)
Parameters
destinationStreamStreamoptionsOdfSaveOptions
Returns
SaveToStreamAsync(Stream, OdfSaveOptions?, CancellationToken)
Full overload of SaveToStreamAsync that accepts destinationStream, options, and cancellationToken. SaveToStreamAsync 完整多載:接受 destinationStream、options 與 cancellationToken。
public Task SaveToStreamAsync(Stream destinationStream, OdfSaveOptions? options, CancellationToken cancellationToken)
Parameters
destinationStreamStreamoptionsOdfSaveOptionscancellationTokenCancellationToken
Returns
SaveToStreamAsync(Stream, CancellationToken)
Asynchronously saves the document to the specified stream with a cancellation token. 以取消語彙基元非同步將文件儲存至指定資料流。
public Task SaveToStreamAsync(Stream destinationStream, CancellationToken cancellationToken)
Parameters
destinationStreamStreamThe destination stream. / 目標資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SetCustomProperty(string, bool)
Sets a Boolean custom metadata property. 設定布林類型的自訂中繼資料屬性。
public void SetCustomProperty(string name, bool value)
Parameters
SetCustomProperty(string, DateTime)
Sets a date custom metadata property. 設定日期類型的自訂中繼資料屬性。
public void SetCustomProperty(string name, DateTime value)
Parameters
SetCustomProperty(string, double)
Sets a floating-point custom metadata property. 設定浮點數類型的自訂中繼資料屬性。
public void SetCustomProperty(string name, double value)
Parameters
SetCustomProperty(string, int)
Sets an integer custom metadata property. 設定整數類型的自訂中繼資料屬性。
public void SetCustomProperty(string name, int value)
Parameters
SetCustomProperty(string, string)
Sets a string custom metadata property. 設定字串類型的自訂中繼資料屬性。
public void SetCustomProperty(string name, string value)
Parameters
Sign(X509Certificate2)
Signs the document with the specified X.509 certificate. 使用指定的 X.509 憑證簽署文件。
public void Sign(X509Certificate2 certificate)
Parameters
certificateX509Certificate2The certificate used to sign the document. / 用於簽署文件的憑證。
Remarks
Prefer SignAsync(X509Certificate2, CancellationToken) in server environments to avoid blocking request threads. 在 ASP.NET Core 等伺服器環境中,請優先使用 SignAsync(X509Certificate2, CancellationToken) 以避免阻塞要求執行緒。
SignAsync(X509Certificate2)
Asynchronously signs the document with the specified X.509 certificate. 非同步使用指定的 X.509 憑證簽署文件。
public Task SignAsync(X509Certificate2 certificate)
Parameters
certificateX509Certificate2
Returns
- Task
A task representing the asynchronous signing operation. / 代表非同步簽署作業的工作。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 DOM 寫入、ZIP 寫入與 HTTP(TSA/CRL)期間協作檢查取消語彙。
SignAsync(X509Certificate2, CancellationToken)
Full overload of SignAsync that accepts certificate and cancellationToken. SignAsync 完整多載:接受 certificate 與 cancellationToken。
public Task SignAsync(X509Certificate2 certificate, CancellationToken cancellationToken)
Parameters
certificateX509Certificate2cancellationTokenCancellationToken
Returns
SignDocumentAsync(X509Certificate2)
Signs document async. 非同步使用指定的 X.509 憑證對文件進行一鍵式數位簽章。
public Task SignDocumentAsync(X509Certificate2 certificate)
Parameters
certificateX509Certificate2
Returns
- Task
代表非同步簽章作業的工作
Remarks
此方法是計畫文件中 SignDocumentAsync 入口的文件層別名;行為等同於
SignAsync(X509Certificate2, CancellationToken)。
SignDocumentAsync(X509Certificate2, OdfSigningOptions?)
Signs document async. 非同步使用指定的 X.509 憑證與簽章選項對文件進行一鍵式數位簽章。
public Task SignDocumentAsync(X509Certificate2 certificate, OdfSigningOptions? options)
Parameters
certificateX509Certificate2optionsOdfSigningOptions
Returns
- Task
代表非同步簽章作業的工作
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 DOM 寫入、ZIP 寫入與 HTTP(TSA/CRL)期間協作檢查取消語彙。
SignDocumentAsync(X509Certificate2, OdfSigningOptions?, CancellationToken)
Full overload of SignDocumentAsync that accepts certificate, options, and cancellationToken. SignDocumentAsync 完整多載:接受 certificate、options 與 cancellationToken。
public Task SignDocumentAsync(X509Certificate2 certificate, OdfSigningOptions? options, CancellationToken cancellationToken)
Parameters
certificateX509Certificate2optionsOdfSigningOptionscancellationTokenCancellationToken
Returns
SignDocumentAsync(X509Certificate2, CancellationToken)
Full overload of SignDocumentAsync that accepts certificate and cancellationToken. SignDocumentAsync 完整多載:接受 certificate 與 cancellationToken。
public Task SignDocumentAsync(X509Certificate2 certificate, CancellationToken cancellationToken)
Parameters
certificateX509Certificate2cancellationTokenCancellationToken
Returns
UpdateDocumentStatistics()
Updates metadata statistics for the current document. 更新文件統計中繼資料。
protected virtual void UpdateDocumentStatistics()
Validate()
Short overload of Validate that uses default values for all optional parameters and forwards to the full overload. 便利多載:Validate 的所有可選參數使用預設值並轉呼叫最長多載。
public OdfValidationReport Validate()
Returns
Validate(OdfComplianceProfile?)
Performs the Validate operation. 驗證目前文件(反映記憶體中尚未儲存的編輯內容)是否符合 ODF 規格。
public OdfValidationReport Validate(OdfComplianceProfile? profile)
Parameters
profileOdfComplianceProfile相容性設定檔;若為 null 則使用預設設定檔
Returns
- OdfValidationReport
結構化驗證結果報告
Remarks
此方法會先將目前 DOM 狀態序列化為記憶體中的暫存封裝(不影響原始 Package 或來源檔案),再交由 OdfValidator 驗證,因此可反映呼叫前所做的任何編輯。
ValidateAsync()
Short overload of ValidateAsync that uses default values for all optional parameters and forwards to the full overload. 便利多載:ValidateAsync 的所有可選參數使用預設值並轉呼叫最長多載。
public Task<OdfValidationReport> ValidateAsync()
Returns
ValidateAsync(OdfComplianceProfile?)
Short overload of ValidateAsync that accepts profile; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 profile;其餘可選參數使用預設值並轉呼叫最長 ValidateAsync 多載。
public Task<OdfValidationReport> ValidateAsync(OdfComplianceProfile? profile)
Parameters
profileOdfComplianceProfile
Returns
ValidateAsync(OdfComplianceProfile?, CancellationToken)
Validates async. 非同步驗證目前文件(反映記憶體中尚未儲存的編輯內容)是否符合 ODF 規格。
public Task<OdfValidationReport> ValidateAsync(OdfComplianceProfile? profile, CancellationToken cancellationToken)
Parameters
profileOdfComplianceProfile相容性設定檔;若為 null 則使用預設設定檔
cancellationTokenCancellationToken取消語彙基元
Returns
- Task<OdfValidationReport>
代表非同步驗證作業的工作,其結果為結構化驗證結果報告
VerifySignatures()
Verifies signatures. 驗證文件中的所有數位簽章,並傳回詳細驗證結果。
public OdfSignatureValidationResult VerifySignatures()
Returns
- OdfSignatureValidationResult
詳細的數位簽章驗證結果
VerifySignatures(OdfSigningOptions?)
Full overload of VerifySignatures that accepts options. VerifySignatures 完整多載:接受 options。
public OdfSignatureValidationResult VerifySignatures(OdfSigningOptions? options)
Parameters
optionsOdfSigningOptions
Returns
VerifySignatures(out X509Certificate2Collection)
Verifies signatures. 驗證文件中的所有數位簽章。
public bool VerifySignatures(out X509Certificate2Collection certificates)
Parameters
certificatesX509Certificate2Collection輸出參數,傳回驗證通過的憑證集合
Returns
- bool
若所有簽章皆驗證成功則傳回 true;否則傳回 false
VerifySignaturesAsync()
Verifies signatures async. 非同步驗證文件中的所有數位簽章,並傳回詳細驗證結果。
public Task<OdfSignatureValidationResult> VerifySignaturesAsync()
Returns
- Task<OdfSignatureValidationResult>
代表非同步驗證作業的工作,其結果包含詳細的數位簽章驗證結果
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在簽章解析與 HTTP(CRL)期間協作檢查取消語彙。
VerifySignaturesAsync(OdfSigningOptions?)
Short overload of VerifySignaturesAsync that accepts options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 options;其餘可選參數使用預設值並轉呼叫最長 VerifySignaturesAsync 多載。
public Task<OdfSignatureValidationResult> VerifySignaturesAsync(OdfSigningOptions? options)
Parameters
optionsOdfSigningOptions
Returns
VerifySignaturesAsync(OdfSigningOptions?, CancellationToken)
Full overload of VerifySignaturesAsync that accepts options and cancellationToken. VerifySignaturesAsync 完整多載:接受 options 與 cancellationToken。
public Task<OdfSignatureValidationResult> VerifySignaturesAsync(OdfSigningOptions? options, CancellationToken cancellationToken)
Parameters
optionsOdfSigningOptionscancellationTokenCancellationToken
Returns
VerifySignaturesAsync(CancellationToken)
Asynchronously verifies all digital signatures with a cancellation token. 以取消語彙基元非同步驗證所有數位簽章。
public Task<OdfSignatureValidationResult> VerifySignaturesAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfSignatureValidationResult>
A task whose result is the detailed signature validation result. / 代表非同步驗證作業的工作,其結果包含詳細的數位簽章驗證結果。