Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

OdfDocument

OfficeIMO.OpenDocument

Namespace
OfficeIMO.OpenDocument
Assembly
OfficeIMO.OpenDocument
Source revision
be6c300e4ab1 with working tree changes
Implements
IDisposable
Modifiers
abstract

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

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 required
path string? = null optional
public void Dispose() #

Completes the document lifecycle without saving.

public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions options, CancellationToken cancellationToken = default) #

Returns native non-XML payload descriptors under explicit inspection limits.

Parameters

options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions required
cancellationToken System.Threading.CancellationToken = default optional

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 required

Returns

long
GetPackageEntryBytes 2 overloads
public byte[] GetPackageEntryBytes(string path) #

Returns a defensive copy of one already-loaded package entry without resolving external links.

Parameters

path string required

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 required
maximumBytes long required

Returns

byte[]
public string? GetPackageEntryMediaType(string reference) #

Declared media type of an already-loaded package entry. External references are never fetched.

Parameters

reference string required

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 required
InspectContentSafety 2 overloads
public 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[] required
options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null optional
loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null optional

Returns

OfficeContentSafetyReport
public 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 required
options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null optional
loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null optional

Returns

OfficeContentSafetyReport
public 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 optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeEmbeddedPayloadInspection
InspectFeatures 2 overloads
public OdfFeatureReport InspectFeatures() #

Inspects supported, preserved, and unsupported document features.

public OdfFeatureReport InspectFeatures(CancellationToken cancellationToken) #

Inspects native package features with cancellation between XML parts, without executing preserved content.

Parameters

cancellationToken System.Threading.CancellationToken required
public OfficeHiddenDataReport InspectHiddenData() #

Finds metadata, personal information and hidden data without changing the document.

Returns

OfficeHiddenDataReport
public 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 optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeContentSafetyReport
Load 2 overloads
public static OdfDocument Load(string path, OdfLoadOptions? options = null) #

Loads an ODT, ODS, or ODP package and returns its native document type.

Parameters

path string required
options OfficeIMO.OpenDocument.OdfLoadOptions? = null optional
public 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 required
options OfficeIMO.OpenDocument.OdfLoadOptions? = null optional
LoadAsync 2 overloads
public 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 required
options OfficeIMO.OpenDocument.OdfLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

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 required
options OfficeIMO.OpenDocument.OdfLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<OdfDocument>
LoadFlatXml 2 overloads
public static OdfDocument LoadFlatXml(Stream stream, OdfLoadOptions? options = null) #

Loads a flat ODT, ODS, ODP, or ODG XML document.

Parameters

stream System.IO.Stream required
options OfficeIMO.OpenDocument.OdfLoadOptions? = null optional
public static OdfDocument LoadFlatXml(string path, OdfLoadOptions? options = null) #

Loads a flat ODT, ODS, ODP, or ODG XML document from a path.

Parameters

path string required
options OfficeIMO.OpenDocument.OdfLoadOptions? = null optional
public static string NormalizePackageEntryPath(string reference) #

Normalizes a package reference through the native owner without fetching or resolving filesystem targets.

Parameters

reference string required

Returns

string
public 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 required
maximumBytes long required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Stream
public OfficeHiddenDataReport RemoveHiddenData(OfficeHiddenDataOptions? options = null) #

Removes the selected categories of metadata and hidden data, then reports what was found and what happened to each item. Save the document to keep the result.

Parameters

options OfficeIMO.OfficeHiddenDataOptions? = null optional
Categories to remove; defaults to OfficeHiddenDataKind.Default, which keeps tracked changes, hidden content and provenance.

Returns

OfficeHiddenDataReport
RemoveProvenance 2 overloads
public static OfficeProvenanceRemovalResult RemoveProvenance(string inputPath, string outputPath, OfficeProvenanceRemovalOptions? options = null) #

Removes selected provenance and atomically writes an ODF package.

Parameters

inputPath string required
outputPath string required
options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null optional

Returns

OfficeProvenanceRemovalResult
public static OfficeProvenanceRemovalResult RemoveProvenance(byte[] packageBytes, string fileName = "document.odt", OfficeProvenanceRemovalOptions? options = null) #

Removes selected provenance from encoded ODF package bytes.

Parameters

packageBytes byte[] required
fileName string = "document.odt" optional
options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null optional

Returns

OfficeProvenanceRemovalResult
RemoveSelectedContent 2 overloads
public 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[] required
selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection required
options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null optional
loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null optional

Returns

OfficeContentCleanupResult
public 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 required
outputPath string required
selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection required
options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null optional
loadOptions OfficeIMO.OpenDocument.OdfLoadOptions? = null optional

Returns

OfficeContentCleanupResult
Save 3 overloads
public 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 optional
public OdfSaveResult Save(string path, OdfSaveOptions? options = null) #

Saves to a path and returns the serialized bytes with entry-level diagnostics.

Parameters

path string required
options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional
public 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 required
options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional
SaveAsync 4 overloads
public 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 optional

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? required
cancellationToken System.Threading.CancellationToken = default optional

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 required
options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

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 required
options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

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 required
options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional
public 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 required
options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<OdfSaveResult>
SaveFlatXml 2 overloads
public OdfSaveResult SaveFlatXml(Stream destination) #

Writes flat OpenDocument XML and returns the serialized bytes with projection diagnostics.

Parameters

destination System.IO.Stream required
public OdfSaveResult SaveFlatXml(string path) #

Writes flat OpenDocument XML to a path and returns the serialized bytes with projection diagnostics.

Parameters

path string required
public 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 optional
public 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 required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null optional

Returns

OfficeXmlPackageSigningResult
public byte[] ToBytes(OdfSaveOptions? options = null) #

Serializes the document to a byte array.

Parameters

options OfficeIMO.OpenDocument.OdfSaveOptions? = null optional

Returns

byte[]
public XDocument ToFlatXml() #

Projects this package into a single flat OpenDocument XML tree.

Returns

XDocument
public 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 required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null optional

Returns

OfficeXmlPackageSigningResult
public OdfValidationResult Validate() #

Validates package and supported semantic invariants.

public 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 required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
options OfficeIMO.Security.OfficeXmlPackageSignatureOptions? = null optional

Returns

OfficeXmlPackageSignatureValidationReport

Properties

public OdfDocumentKind Kind { get; } #

Document kind.

public string? FilePath { get; } #

Gets the file path associated with the document, if any.

public OdfVersion Version { get; } #

Source or current output version.

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.