Aspose::Words::Saving::OdtSaveOptions::get_SaveFormat method
Contents
[
Hide
]OdtSaveOptions::get_SaveFormat method
Specifies the format in which the document will be saved if this save options object is used. Can be Odt or Ott.
Aspose::Words::SaveFormat Aspose::Words::Saving::OdtSaveOptions::get_SaveFormat() override
Examples
Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Create a new OdtSaveOptions, and pass either "SaveFormat.Odt",
// or "SaveFormat.Ott" as the format to save the document in.
auto saveOptions = System::MakeObject<Aspose::Words::Saving::OdtSaveOptions>(saveFormat);
saveOptions->set_Password(u"@sposeEncrypted_1145");
System::String extensionString = Aspose::Words::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(get_ArtifactsDir() + u"OdtSaveOptions.Encrypt" + extensionString, saveOptions);
System::SharedPtr<Aspose::Words::FileFormatInfo> docInfo = Aspose::Words::FileFormatUtil::DetectFileFormat(get_ArtifactsDir() + u"OdtSaveOptions.Encrypt" + extensionString);
ASSERT_TRUE(docInfo->get_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 = System::MakeObject<Aspose::Words::Document>(get_ArtifactsDir() + u"OdtSaveOptions.Encrypt" + extensionString, System::MakeObject<Aspose::Words::Loading::LoadOptions>(u"@sposeEncrypted_1145"));
ASSERT_EQ(u"Hello world!", doc->GetText().Trim());
See Also
- Enum SaveFormat
- Class OdtSaveOptions
- Namespace Aspose::Words::Saving
- Library Aspose.Words for C++