LoadOptions class

LoadOptions class

Allows to specify additional options (such as password or base URI) when loading a document into a Document object. To learn more, visit the Specify Load Options documentation article.

Constructors

NameDescription
LoadOptions()Initializes a new instance of this class with default values.
LoadOptions(password)A shortcut to initialize a new instance of this class with the specified password to load an encrypted document.
LoadOptions(load_format, password, base_uri)A shortcut to initialize a new instance of this class with properties set to the specified values.

Properties

NameDescription
base_uriGets or sets the string that will be used to resolve relative URIs found in the document into absolute URIs when required. Can be None or empty string. Default is None.
convert_metafiles_to_pngGets or sets whether to convert metafile(Wmf or Emf) images to Png image format.
convert_shape_to_office_mathGets or sets whether to convert shapes with EquationXML to Office Math objects.
encodingGets or sets the encoding that will be used to load an HTML, TXT, or CHM document if the encoding is not specified inside the document. Can be None. Default is None.
font_settingsAllows to specify document font settings.
ignore_ole_dataSpecifies whether to ignore the OLE data.
language_preferencesGets language preferences that will be used when document is loading.
load_formatSpecifies the format of the document to be loaded. Default is LoadFormat.AUTO.
msw_versionAllows to specify that the document loading process should match a specific MS Word version. Default value is MsWordVersion.WORD2019
passwordGets or sets the password for opening an encrypted document. Can be None or empty string. Default is None.
preserve_include_picture_fieldGets or sets whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is False.
progress_callbackCalled during loading a document and accepts data about loading progress.
resource_loading_callbackAllows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.
temp_folderAllows to use temporary files when reading document. By default this property is None and no temporary files are used.
update_dirty_fieldsSpecifies whether to update the fields with the dirty attribute.
warning_callbackCalled during a load operation, when an issue is detected that might result in data or formatting fidelity loss.

Examples

Shows how to load an encrypted Microsoft Word document.

# Aspose.Words throw an exception if we try to open an encrypted document without its password.
with self.assertRaises(Exception):
    doc = aw.Document(MY_DIR + "Encrypted.docx")

# When loading such a document, the password is passed to the document's constructor using a LoadOptions object.
options = aw.loading.LoadOptions("docPassword")

# There are two ways of loading an encrypted document with a LoadOptions object.
# 1 -  Load the document from the local file system by filename:
doc = aw.Document(MY_DIR + "Encrypted.docx", options)

# 2 -  Load the document from a stream:
with open(MY_DIR + "Encrypted.docx", "rb") as stream:
    doc = aw.Document(stream, options)

See Also