OdtSaveOptions constructor

OdtSaveOptions()

Initializes a new instance of this class that can be used to save a document in the SaveFormat.ODT format.

def __init__(self):
    ...

OdtSaveOptions(password)

Initializes a new instance of this class that can be used to save a document in the SaveFormat.ODT format encrypted with a password.

def __init__(self, password: str):
    ...
ParameterTypeDescription
passwordstr

OdtSaveOptions(save_format)

Initializes a new instance of this class that can be used to save a document in the SaveFormat.ODT or SaveFormat.OTT format.

def __init__(self, save_format: aspose.words.SaveFormat):
    ...
ParameterTypeDescription
save_formatSaveFormatCan be SaveFormat.ODT or SaveFormat.OTT.

Examples

Shows how to make a saved document conform to an older ODT schema.

doc = aw.Document(MY_DIR + 'Rendering.docx')
save_options = aw.saving.OdtSaveOptions()
save_options.measure_unit = aw.saving.OdtSaveMeasureUnit.CENTIMETERS
save_options.is_strict_schema11 = export_to_odt11_specs
doc.save(ARTIFACTS_DIR + 'OdtSaveOptions.odt11_schema.odt', save_options)

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)
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_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(ARTIFACTS_DIR + 'OdtSaveOptions.encrypt' + extension_string, save_options)
doc_info = aw.FileFormatUtil.detect_file_format(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(ARTIFACTS_DIR + 'OdtSaveOptions.encrypt' + extension_string, aw.loading.LoadOptions('@sposeEncrypted_1145'))
self.assertEqual('Hello world!', doc.get_text().strip())

See Also