API Reference
OdfDocument
Common package lifecycle for ODT, ODS, and ODP documents.
Inheritance
- Object
- OdfDocument
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Method OdfDocument.Load
- Method OdfDocument.Load
- Method OdfDocument.LoadAsync
- Method OdfDocument.LoadAsync
- Method OdfDocument.LoadFlatXml
- Method OdfDocument.LoadFlatXml
Methods
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 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
- arg1 System.Byte[]
- arg2 OfficeIMO.ContentSafety.OfficeContentSafetyOptions = null
- arg3 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
- arg1 System.String
- arg2 OfficeIMO.ContentSafety.OfficeContentSafetyOptions = null
- arg3 OfficeIMO.OpenDocument.OdfLoadOptions = null
public OdfFeatureReport InspectFeatures() #OdfFeatureReportInspects supported, preserved, and unsupported document features.
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 = null) #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 = null
public static async Task<OdfDocument> LoadAsync(Stream stream, OdfLoadOptions options = null, CancellationToken cancellationToken = null) #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 = null
public static OdfDocument LoadFlatXml(Stream stream, OdfLoadOptions options = null) #OdfDocumentLoads a flat ODT, ODS, or ODP 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, or ODP XML document from a path.
Parameters
- path System.String
- options OfficeIMO.OpenDocument.OdfLoadOptions = null
public static OfficeProvenanceRemovalResult RemoveProvenance(String inputPath, String outputPath, OfficeProvenanceRemovalOptions options = null) #OfficeProvenanceRemovalResultRemoves selected provenance and atomically writes an ODF package.
Parameters
- arg1 System.String
- arg2 System.String
- arg3 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
- arg1 System.Byte[]
- arg2 System.String = "document.odt"
- arg3 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 = null) #Task<OdfSaveResult>Asynchronously saves to the original path used to load or first save the document.
Parameters
- cancellationToken System.Threading.CancellationToken = null
public Task<OdfSaveResult> SaveAsync(OdfSaveOptions options, CancellationToken cancellationToken = null) #Task<OdfSaveResult>Asynchronously saves to the original path with optional save settings.
Parameters
- options OfficeIMO.OpenDocument.OdfSaveOptions
- cancellationToken System.Threading.CancellationToken = null
public async Task<OdfSaveResult> SaveAsync(String path, OdfSaveOptions options = null, CancellationToken cancellationToken = null) #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 = null
public async Task<OdfSaveResult> SaveAsync(Stream destination, OdfSaveOptions options = null, CancellationToken cancellationToken = null) #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 = null
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 = null) #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 = null
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
Properties
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 Metadata { get; } #Document metadata.
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.