save_format property
OdtSaveOptions.save_format property
Specifies the format in which the document will be saved if this save options object is used. Can be SaveFormat.ODT or SaveFormat.OTT.
@property
def save_format(self) -> aspose.words.SaveFormat:
...
@save_format.setter
def save_format(self, value: aspose.words.SaveFormat):
...
Examples
Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=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.
save_options = aw.saving.OdtSaveOptions(save_format=save_format)
save_options.password = '@sposeEncrypted_1145'
extension_string = aw.FileFormatUtil.save_format_to_extension(save_format)
# If we open this document with an appropriate editor,
# it will prompt us for the password we specified in the SaveOptions object.
doc.save(file_name=ARTIFACTS_DIR + 'OdtSaveOptions.Encrypt' + extension_string, save_options=save_options)
doc_info = aw.FileFormatUtil.detect_file_format(file_name=ARTIFACTS_DIR + 'OdtSaveOptions.Encrypt' + extension_string)
self.assertTrue(doc_info.is_encrypted)
# 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 = aw.Document(file_name=ARTIFACTS_DIR + 'OdtSaveOptions.Encrypt' + extension_string, load_options=aw.loading.LoadOptions(password='@sposeEncrypted_1145'))
self.assertEqual('Hello world!', doc.get_text().strip())
See Also
- module aspose.words.saving
- class OdtSaveOptions