SaveFormat
Contents
[
Hide
]OdtSaveOptions.SaveFormat property
Specifies the format in which the document will be saved if this save options object is used. Can be Odt or Ott.
public override SaveFormat SaveFormat { get; set; }
Examples
Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
// Create a new OdtSaveOptions, and pass either "SaveFormat.Odt",
// or "SaveFormat.Ott" as the format to save the document in.
OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat);
saveOptions.Password = "@sposeEncrypted_1145";
string extensionString = FileFormatUtil.SaveFormatToExtension(saveFormat);
// If we open this document with an appropriate editor,
// it will prompt us for the password we specified in the SaveOptions object.
doc.Save(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString, saveOptions);
FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString);
Assert.IsTrue(docInfo.IsEncrypted);
// If we wish to open or edit this document again using Aspose.Words,
// we will have to provide a LoadOptions object with the correct password to the loading constructor.
doc = new Document(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString,
new LoadOptions("@sposeEncrypted_1145"));
Assert.AreEqual("Hello world!", doc.GetText().Trim());
See Also
- enum SaveFormat
- class OdtSaveOptions
- namespace Aspose.Words.Saving
- assembly Aspose.Words