API Reference
OdfDocument
Common package lifecycle for ODT, ODS, and ODP documents.
Inheritance
- Object
- OdfDocument
Usage
Explore 3 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 3
- Method OdfDocument.Load
- Method OdfDocument.LoadAsync
- Method OdfDocument.LoadFlatXml
Methods
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions options, CancellationToken cancellationToken = default) #IReadOnlyList<OfficeEmbeddedPayloadInfo>Returns native non-XML payload descriptors under explicit inspection limits.
Parameters
- options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions
- cancellationToken System.Threading.CancellationToken = default
public Int64 GetPackageEntryByteLength(String reference) #Int64Decoded or declared byte length of a package entry without expanding a deferred binary payload.
Parameters
- reference System.String
public Byte[] GetPackageEntryBytes(String path) #Byte[]Returns a defensive copy of one already-loaded package entry without resolving external links.
Parameters
- path System.String
public Byte[] GetPackageEntryBytes(String path, Int64 maximumBytes) #Byte[]Returns an already-loaded entry within an explicit byte ceiling, checked before creating its defensive copy. External links are never resolved.
Parameters
- path System.String
- maximumBytes System.Int64
public String? GetPackageEntryMediaType(String reference) #String?Declared media type of an already-loaded package entry. External references are never fetched.
Parameters
- reference System.String
public OdfPackageEntryPayloadState GetPackageEntryPayloadState(String reference) #OdfPackageEntryPayloadStateReports whether native entry bytes are deferred, fully loaded or checked by the supported ODF decryption profile.
Parameters
- reference System.String
public static OfficeContentSafetyReport InspectContentSafety(Byte[] documentBytes, OfficeContentSafetyOptions? options = null, OdfLoadOptions? loadOptions = null) #OfficeContentSafetyReportInspects ODT, ODS, or ODP native visibility, geometry, contrast, notes, comments, and Unicode evidence.
Parameters
- documentBytes System.Byte[]
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
public static OfficeContentSafetyReport InspectContentSafety(String filePath, OfficeContentSafetyOptions? options = null, OdfLoadOptions? loadOptions = null) #OfficeContentSafetyReportInspects an OpenDocument package without treating concealment as evidence of AI authorship.
Parameters
- filePath System.String
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
public OfficeEmbeddedPayloadInspection InspectEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions? options = null, CancellationToken cancellationToken = default) #OfficeEmbeddedPayloadInspectionInventories 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
public OdfFeatureReport InspectFeatures() #OdfFeatureReportInspects supported, preserved, and unsupported document features.
public OdfFeatureReport InspectFeatures(CancellationToken cancellationToken) #OdfFeatureReportInspects native package features with cancellation between XML parts, without executing preserved content.
Parameters
- cancellationToken System.Threading.CancellationToken
public OfficeContentSafetyReport InspectLoadedContentSafety(OfficeContentSafetyOptions? options = null, CancellationToken cancellationToken = default) #OfficeContentSafetyReportInspects 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
public static OfficeProvenanceReport InspectProvenance(String filePath, OfficeProvenanceOptions? options = null) #OfficeProvenanceReportInspects C2PA and IPTC provenance in an ODF package and its supported embedded images.
Parameters
- filePath System.String
- options OfficeIMO.Provenance.OfficeProvenanceOptions? = null
public static OdfDocument Load(String path, OdfLoadOptions? options = null) #OdfDocumentLoads an ODT, ODS, or ODP package and returns its native document type.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
public static OdfDocument Load(Stream stream, OdfLoadOptions? options = null) #OdfDocumentLoads an ODT, ODS, or ODP stream and returns its native document type.
Parameters
- stream System.IO.Stream
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
public static async Task<OdfDocument> LoadAsync(String path, OdfLoadOptions? options = null, CancellationToken cancellationToken = default) #Task<OdfDocument>Asynchronously loads an ODT, ODS, or ODP package from a path.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public static async Task<OdfDocument> LoadAsync(Stream stream, OdfLoadOptions? options = null, CancellationToken cancellationToken = default) #Task<OdfDocument>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
public static OdfDocument LoadFlatXml(Stream stream, OdfLoadOptions? options = null) #OdfDocumentLoads a flat ODT, ODS, ODP, or ODG XML document.
Parameters
- stream System.IO.Stream
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
public static OdfDocument LoadFlatXml(String path, OdfLoadOptions? options = null) #OdfDocumentLoads a flat ODT, ODS, ODP, or ODG XML document from a path.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfLoadOptions? = null
public static String NormalizePackageEntryPath(String reference) #StringNormalizes a package reference through the native owner without fetching or resolving filesystem targets.
Parameters
- reference System.String
public Stream OpenEmbeddedPayload(String id, Int64 maximumBytes, CancellationToken cancellationToken = default) #StreamReads one complete inert non-XML native package payload under an explicit decoded byte ceiling.
Parameters
- id System.String
- maximumBytes System.Int64
- cancellationToken System.Threading.CancellationToken = default
public static OfficeProvenanceRemovalResult RemoveProvenance(String inputPath, String outputPath, OfficeProvenanceRemovalOptions? options = null) #OfficeProvenanceRemovalResultRemoves selected provenance and atomically writes an ODF package.
Parameters
- inputPath System.String
- outputPath System.String
- options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null
public static OfficeProvenanceRemovalResult RemoveProvenance(Byte[] packageBytes, String fileName = "document.odt", OfficeProvenanceRemovalOptions? options = null) #OfficeProvenanceRemovalResultRemoves selected provenance from encoded ODF package bytes.
Parameters
- packageBytes System.Byte[]
- fileName System.String = "document.odt"
- options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null
public static OfficeContentCleanupResult RemoveSelectedContent(Byte[] documentBytes, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null, OdfLoadOptions? loadOptions = null) #OfficeContentCleanupResultRemoves exact selected OpenDocument text nodes and verifies the preservation-aware rewritten package.
Parameters
- documentBytes System.Byte[]
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
public static OfficeContentCleanupResult RemoveSelectedContent(String inputPath, String outputPath, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null, OdfLoadOptions? loadOptions = null) #OfficeContentCleanupResultAtomically writes an explicitly cleaned OpenDocument artifact.
Parameters
- inputPath System.String
- outputPath System.String
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
- loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null
public OdfSaveResult Save(OdfSaveOptions? options = null) #OdfSaveResultSaves to the current path and returns the serialized bytes with entry-level diagnostics.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public OdfSaveResult Save(String path, OdfSaveOptions? options = null) #OdfSaveResultSaves to a path and returns the serialized bytes with entry-level diagnostics.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public OdfSaveResult Save(Stream destination, OdfSaveOptions? options = null) #OdfSaveResultWrites to a stream and returns the serialized bytes with entry-level diagnostics.
Parameters
- destination System.IO.Stream
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public Task<OdfSaveResult> SaveAsync(CancellationToken cancellationToken = default) #Task<OdfSaveResult>Asynchronously saves to the original path used to load or first save the document.
Parameters
- cancellationToken System.Threading.CancellationToken = default
public Task<OdfSaveResult> SaveAsync(OdfSaveOptions? options, CancellationToken cancellationToken = default) #Task<OdfSaveResult>Asynchronously saves to the original path with optional save settings.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions?
- cancellationToken System.Threading.CancellationToken = default
public async Task<OdfSaveResult> SaveAsync(String path, OdfSaveOptions? options = null, CancellationToken cancellationToken = default) #Task<OdfSaveResult>Asynchronously saves to a path and returns the serialized bytes with entry-level diagnostics.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public async Task<OdfSaveResult> SaveAsync(Stream destination, OdfSaveOptions? options = null, CancellationToken cancellationToken = default) #Task<OdfSaveResult>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
public OdfSaveResult SaveCopy(String path, OdfSaveOptions? options = null) #OdfSaveResultSaves an independent copy and returns entry-level diagnostics without changing the associated path.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public async Task<OdfSaveResult> SaveCopyAsync(String path, OdfSaveOptions? options = null, CancellationToken cancellationToken = default) #Task<OdfSaveResult>Asynchronously saves an independent copy and returns entry-level diagnostics without changing the associated path.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
public OdfSaveResult SaveFlatXml(Stream destination) #OdfSaveResultWrites flat OpenDocument XML and returns the serialized bytes with projection diagnostics.
Parameters
- destination System.IO.Stream
public OdfSaveResult SaveFlatXml(String path) #OdfSaveResultWrites flat OpenDocument XML to a path and returns the serialized bytes with projection diagnostics.
Parameters
- path System.String
public OdfSaveResult Serialize(OdfSaveOptions? options = null) #OdfSaveResultSerializes without accepting the current dirty state and returns the bytes with entry-level diagnostics.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public static OfficeXmlPackageSigningResult SignPackage(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeXmlPackageSignatureOptions? options = null) #OfficeXmlPackageSigningResultCreates, validates, and atomically commits an ODF XML package signature.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null
public Byte[] ToBytes(OdfSaveOptions? options = null) #Byte[]Serializes the document to a byte array.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public XDocument ToFlatXml() #XDocumentProjects this package into a single flat OpenDocument XML tree.
public MemoryStream ToStream(OdfSaveOptions? options = null) #MemoryStreamSerializes the document in a new writable memory stream positioned at the beginning.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions? = null
public static OfficeXmlPackageSigningResult TrySignPackage(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeXmlPackageSignatureOptions? options = null) #OfficeXmlPackageSigningResultAttempts atomic ODF XML signature creation and returns structured failure evidence.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null
public OdfValidationResult Validate() #OdfValidationResultValidates package and supported semantic invariants.
public static OfficeXmlPackageSignatureValidationReport ValidatePackageSignatures(String filePath, IOfficeSecurityProvider securityProvider, OfficeXmlPackageSignatureOptions? options = null) #OfficeXmlPackageSignatureValidationReportValidates META-INF/documentsignatures.xml and signed package-entry digests through an explicit provider.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
Properties
public String? FilePath { get; } #Gets the file path associated with the document, if any.
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.