LoadOptions Class

Allows to specify additional options (such as password or base URI) when loading a document into a Document object.

Inheritance Hierarchy

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0

Syntax

public class LoadOptions

The LoadOptions type exposes the following members.

Constructors

  NameDescription
Public methodCode exampleLoadOptions
Initializes a new instance of this class with default values.
Public methodCode exampleLoadOptions(String)
A shortcut to initialize a new instance of this class with the specified password to load an encrypted document.
Public methodCode exampleLoadOptions(LoadFormat, String, String)
A shortcut to initialize a new instance of this class with properties set to the specified values.

Properties

  NameDescription
Public propertyCode exampleBaseUri
Gets or sets the string that will be used to resolve relative URIs found in the document into absolute URIs when required. Can be null or empty string. Default is null.
Public propertyCode exampleConvertShapeToOfficeMath
Gets or sets whether to convert shapes with EquationXML to Office Math objects.
Public propertyCode exampleEncoding
Gets or sets the encoding that will be used to load an HTML or TXT document if the encoding is not specified in HTML/TXT. Can be null. Default is null.
Public propertyCode exampleFontSettings
Allows to specify document font settings.
Public propertyCode exampleLanguagePreferences
Gets language preferences that will be used when document is loading.
Public propertyCode exampleLoadFormat
Specifies the format of the document to be loaded. Default is Auto.
Public propertyCode exampleMswVersion
Allows to specify that the document loading process should match a specific MS Word version. Default value is Word2007
Public propertyCode examplePassword
Gets or sets the password for opening an encrypted document. Can be null or empty string. Default is null.
Public propertyCode examplePreserveIncludePictureField
Gets or sets whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is false.
Public propertyCode exampleResourceLoadingCallback
Allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.
Public propertyCode exampleTempFolder
Allows to use temporary files when reading document. By default this property is null and no temporary files are used.
Public propertyCode exampleUpdateDirtyFields
Specifies whether to update the fields with the dirty attribute.
Public propertyCode exampleWarningCallback
Called during a load operation, when an issue is detected that might result in data or formatting fidelity loss.

Methods

  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)

Examples

Shows how to load a Microsoft Word document encrypted with a password.
// If we try open an encrypted document without the password, an IncorrectPasswordException will be thrown
// We can construct a LoadOptions object with the correct encryption password
LoadOptions options = new LoadOptions("docPassword");

// Then, we can use that object as a parameter when opening an encrypted document
Document doc = new Document(MyDir + "Encrypted.docx", options);

using (Stream stream = File.OpenRead(MyDir + "Encrypted.docx"))
{
    doc = new Document(stream, options);
}

See Also