OdfDocument
OfficeIMO.OpenDocument
Common package lifecycle for ODT, ODS, and ODP documents.
Inheritance
- object
- OdfDocument
Derived Types
Usage
Explore 4 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 4
- Method OdfDocument.Create
- Method OdfDocument.Load
- Method OdfDocument.LoadAsync
- Method OdfDocument.LoadFlatXml
Methods
public static OdfDocument Create(OdfDocumentKind kind, string? path = null) #Creates an empty ODF 1.4 model with an optional associated save path, without writing a file.
Parameters
- kind OfficeIMO.OpenDocument.OdfDocumentKind
- path string? = null
Returns
OdfDocumentpublic IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions options, CancellationToken cancellationToken = default) #Returns native non-XML payload descriptors under explicit inspection limits.
Parameters
- options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions
- cancellationToken System.Threading.CancellationToken = default
Returns
IReadOnlyList<OfficeEmbeddedPayloadInfo>public long GetPackageEntryByteLength(string reference) #Decoded or declared byte length of a package entry without expanding a deferred binary payload.
Parameters
- reference string
Returns
longpublic byte[] GetPackageEntryBytes(string path) #Returns a defensive copy of one already-loaded package entry without resolving external links.
Parameters
- path string
Returns
byte[]public byte[] GetPackageEntryBytes(string path, long maximumBytes) #Returns an already-loaded entry within an explicit byte ceiling, checked before creating its defensive copy. External links are never resolved.
Parameters
- path string
- maximumBytes long
Returns
byte[]public string? GetPackageEntryMediaType(string reference) #Declared media type of an already-loaded package entry. External references are never fetched.
Parameters
- reference string
Returns
string?public OdfPackageEntryPayloadState GetPackageEntryPayloadState(string reference) #Reports whether native entry bytes are deferred, fully loaded or checked by the supported ODF decryption profile.
Parameters
- reference string
Returns
OdfPackageEntryPayloadStatepublic static OfficeContentSafetyReport InspectContentSafety(byte[] documentBytes, OfficeContentSafetyOptions? options = null, OdfLoadOptions? loadOptions = null) #Inspects ODT, ODS, or ODP native visibility, geometry, contrast, notes, comments, and Unicode evidence.
Parameters
- documentBytes byte[]
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OfficeContentSafetyReportpublic static OfficeContentSafetyReport InspectContentSafety(string filePath, OfficeContentSafetyOptions? options = null, OdfLoadOptions? loadOptions = null) #Inspects an OpenDocument package without treating concealment as evidence of AI authorship.
Parameters
- filePath string
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OfficeContentSafetyReportpublic OfficeEmbeddedPayloadInspection InspectEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions? options = null, CancellationToken cancellationToken = default) #Inventories inert non-XML package payloads without expanding deferred entries unless hashing is requested. The session snapshots native entry identities and content sources; later edits do not replace its selected bytes.
Parameters
- options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeEmbeddedPayloadInspectionpublic OdfFeatureReport InspectFeatures() #Inspects supported, preserved, and unsupported document features.
Returns
OdfFeatureReportpublic OdfFeatureReport InspectFeatures(CancellationToken cancellationToken) #Inspects native package features with cancellation between XML parts, without executing preserved content.
Parameters
- cancellationToken System.Threading.CancellationToken
Returns
OdfFeatureReportpublic OfficeContentSafetyReport InspectLoadedContentSafety(OfficeContentSafetyOptions? options = null, CancellationToken cancellationToken = default) #Inspects the loaded native package without serialization, external-resource access, or mutation. Source-load limits remain the caller's responsibility.
Parameters
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeContentSafetyReportpublic static OdfDocument Load(string path, OdfLoadOptions? options = null) #Loads an ODT, ODS, or ODP package and returns its native document type.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OdfDocumentpublic static OdfDocument Load(Stream stream, OdfLoadOptions? options = null) #Loads an ODT, ODS, or ODP stream and returns its native document type.
Parameters
- stream System.IO.Stream
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OdfDocumentpublic static async Task<OdfDocument> LoadAsync(string path, OdfLoadOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously loads an ODT, ODS, or ODP package from a path.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfDocument>public static async Task<OdfDocument> LoadAsync(Stream stream, OdfLoadOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously loads an ODT, ODS, or ODP package from a caller-owned stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfDocument>public static OdfDocument LoadFlatXml(Stream stream, OdfLoadOptions? options = null) #Loads a flat ODT, ODS, ODP, or ODG XML document.
Parameters
- stream System.IO.Stream
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OdfDocumentpublic static OdfDocument LoadFlatXml(string path, OdfLoadOptions? options = null) #Loads a flat ODT, ODS, ODP, or ODG XML document from a path.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OdfDocumentpublic static string NormalizePackageEntryPath(string reference) #Normalizes a package reference through the native owner without fetching or resolving filesystem targets.
Parameters
- reference string
Returns
stringpublic Stream OpenEmbeddedPayload(string id, long maximumBytes, CancellationToken cancellationToken = default) #Reads one complete inert non-XML native package payload under an explicit decoded byte ceiling.
Parameters
- id string
- maximumBytes long
- cancellationToken System.Threading.CancellationToken = default
Returns
Streampublic static OfficeProvenanceRemovalResult RemoveProvenance(string inputPath, string outputPath, OfficeProvenanceRemovalOptions? options = null) #Removes selected provenance and atomically writes an ODF package.
Parameters
- inputPath string
- outputPath string
- options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null
Returns
OfficeProvenanceRemovalResultpublic static OfficeProvenanceRemovalResult RemoveProvenance(byte[] packageBytes, string fileName = "document.odt", OfficeProvenanceRemovalOptions? options = null) #Removes selected provenance from encoded ODF package bytes.
Parameters
- packageBytes byte[]
- fileName string = "document.odt"
- options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null
Returns
OfficeProvenanceRemovalResultpublic static OfficeContentCleanupResult RemoveSelectedContent(byte[] documentBytes, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null, OdfLoadOptions? loadOptions = null) #Removes exact selected OpenDocument text nodes and verifies the preservation-aware rewritten package.
Parameters
- documentBytes byte[]
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OfficeContentCleanupResultpublic static OfficeContentCleanupResult RemoveSelectedContent(string inputPath, string outputPath, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null, OdfLoadOptions? loadOptions = null) #Atomically writes an explicitly cleaned OpenDocument artifact.
Parameters
- inputPath string
- outputPath string
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
Returns
OfficeContentCleanupResultpublic OdfSaveResult Save(OdfSaveOptions? options = null) #Saves to the current path and returns the serialized bytes with entry-level diagnostics.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
Returns
OdfSaveResultpublic OdfSaveResult Save(string path, OdfSaveOptions? options = null) #Saves to a path and returns the serialized bytes with entry-level diagnostics.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
Returns
OdfSaveResultpublic OdfSaveResult Save(Stream destination, OdfSaveOptions? options = null) #Writes to a stream and returns the serialized bytes with entry-level diagnostics.
Parameters
- destination System.IO.Stream
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
Returns
OdfSaveResultpublic Task<OdfSaveResult> SaveAsync(CancellationToken cancellationToken = default) #Asynchronously saves to the original path used to load or first save the document.
Parameters
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfSaveResult>public Task<OdfSaveResult> SaveAsync(OdfSaveOptions? options, CancellationToken cancellationToken = default) #Asynchronously saves to the original path with optional save settings.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions?
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfSaveResult>public async Task<OdfSaveResult> SaveAsync(string path, OdfSaveOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously saves to a path and returns the serialized bytes with entry-level diagnostics.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfSaveResult>public async Task<OdfSaveResult> SaveAsync(Stream destination, OdfSaveOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously writes to a stream and returns the serialized bytes with entry-level diagnostics.
Parameters
- destination System.IO.Stream
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfSaveResult>public OdfSaveResult SaveCopy(string path, OdfSaveOptions? options = null) #Saves an independent copy and returns entry-level diagnostics without changing the associated path.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
Returns
OdfSaveResultpublic async Task<OdfSaveResult> SaveCopyAsync(string path, OdfSaveOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously saves an independent copy and returns entry-level diagnostics without changing the associated path.
Parameters
- path string
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<OdfSaveResult>public OdfSaveResult SaveFlatXml(Stream destination) #Writes flat OpenDocument XML and returns the serialized bytes with projection diagnostics.
Parameters
- destination System.IO.Stream
Returns
OdfSaveResultpublic OdfSaveResult SaveFlatXml(string path) #Writes flat OpenDocument XML to a path and returns the serialized bytes with projection diagnostics.
Parameters
- path string
Returns
OdfSaveResultpublic OdfSaveResult Serialize(OdfSaveOptions? options = null) #Serializes without accepting the current dirty state and returns the bytes with entry-level diagnostics.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
Returns
OdfSaveResultpublic static OfficeXmlPackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeXmlPackageSignatureOptions? options = null) #Creates, validates, and atomically commits an ODF XML package signature.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null
Returns
OfficeXmlPackageSigningResultpublic byte[] ToBytes(OdfSaveOptions? options = null) #Serializes the document to a byte array.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
Returns
byte[]public XDocument ToFlatXml() #Projects this package into a single flat OpenDocument XML tree.
Returns
XDocumentpublic static OfficeXmlPackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeXmlPackageSignatureOptions? options = null) #Attempts atomic ODF XML signature creation and returns structured failure evidence.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null
Returns
OfficeXmlPackageSigningResultpublic OdfValidationResult Validate() #Validates package and supported semantic invariants.
Returns
OdfValidationResultpublic static OfficeXmlPackageSignatureValidationReport ValidateSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficeXmlPackageSignatureOptions? options = null) #Validates META-INF/documentsignatures.xml and signed package-entry digests through an explicit provider.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null
Returns
OfficeXmlPackageSignatureValidationReportInherited Methods
Properties
public string? FilePath { get; } #Gets the file path associated with the document, if any.
public OdfDocumentMetadata Properties { get; } #Standard and user-defined document properties stored in meta.xml.
public OdfStyleRepository Styles { get; } #Named and automatic styles stored in the document.
public IReadOnlyList<OdfDiagnostic> Diagnostics { get; } #Non-fatal diagnostics produced while opening the package.
public OdfSecurityInfo Security { get; } #Password-protection state for the package loaded or most recently saved.
public IReadOnlyList<string> PackageEntries { get; } #Package entry paths currently stored in the document.
public IReadOnlyList<string> BinaryPayloadEntries { get; } #Native non-XML/control payload paths in package order; excludes directory records, mimetype, XML and RDF metadata parts.