Class LoadOptions

Class LoadOptions

Namespace: Aspose.Words.Loading
Assembly: Aspose.Words.dll (25.3.0)

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

To learn more, visit the Specify Load Options documentation article.

public class LoadOptions

Inheritance

objectLoadOptions

Derived

ChmLoadOptions, HtmlLoadOptions, MarkdownLoadOptions, PdfLoadOptions, RtfLoadOptions, TxtLoadOptions

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

LoadOptions()

Initializes a new instance of this class with default values.

public LoadOptions()

LoadOptions(string)

A shortcut to initialize a new instance of this class with the specified password to load an encrypted document.

public LoadOptions(string password)

Parameters

password string

The password to open an encrypted document. Can be null or empty string.

LoadOptions(LoadFormat, string, string)

A shortcut to initialize a new instance of this class with properties set to the specified values.

public LoadOptions(LoadFormat loadFormat, string password, string baseUri)

Parameters

loadFormat LoadFormat

The format of the document to be loaded.

password string

The password to open an encrypted document. Can be null or empty string.

baseUri string

The string that will be used to resolve relative URIs to absolute. Can be null or empty string.

Properties

BaseUri

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 string BaseUri { get; set; }

Property Value

string

Remarks

This property is used to resolve relative URIs into absolute in the following cases:

  1. When loading an HTML document from a stream and the document contains images with relative URIs and does not have a base URI specified in the BASE HTML element.
  2. When saving a document to PDF and other formats, to retrieve images linked using relative URIs so the images can be saved into the output document.

ConvertMetafilesToPng

Gets or sets whether to convert metafile(Aspose.FileFormat.Wmf or Aspose.FileFormat.Emf) images to Aspose.FileFormat.Png image format.

public bool ConvertMetafilesToPng { get; set; }

Property Value

bool

Remarks

Metafiles (Aspose.FileFormat.Wmf or Aspose.FileFormat.Emf) is an uncompressed image format and sometimes requires to much RAM to hold and process document. This option allows to convert all metafile images to Aspose.FileFormat.Png on document loading. Please note - conversion vector graphics to raster decreases quality of the images.

ConvertShapeToOfficeMath

Gets or sets whether to convert shapes with EquationXML to Office Math objects.

public bool ConvertShapeToOfficeMath { get; set; }

Property Value

bool

Encoding

Gets 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 null. Default is null.

public Encoding Encoding { get; set; }

Property Value

Encoding

Remarks

This property is used only when loading HTML, TXT, or CHM documents.

If encoding is not specified inside the document and this property is null, then the system will try to automatically detect the encoding.

FontSettings

Allows to specify document font settings.

public FontSettings FontSettings { get; set; }

Property Value

FontSettings

Remarks

When loading some formats, Aspose.Words may require to resolve the fonts. For example, when loading HTML documents Aspose.Words may resolve the fonts to perform font fallback.

If set to null, default static font settings Aspose.Words.Fonts.FontSettings.DefaultInstance will be used.

The default value is null.

IgnoreOleData

Specifies whether to ignore the OLE data.

public bool IgnoreOleData { get; set; }

Property Value

bool

Remarks

Ignoring OLE data may reduce memory consumption and increase performance without data lost in a case when destination format does not support OLE objects.

The default value is false.

LanguagePreferences

Gets language preferences that will be used when document is loading.

public LanguagePreferences LanguagePreferences { get; }

Property Value

LanguagePreferences

LoadFormat

Specifies the format of the document to be loaded. Default is Aspose.Words.LoadFormat.Auto.

public LoadFormat LoadFormat { get; set; }

Property Value

LoadFormat

Remarks

It is recommended that you specify the Aspose.Words.LoadFormat.Auto value and let Aspose.Words detect the file format automatically. If you know the format of the document you are about to load, you can specify the format explicitly and this will slightly reduce the loading time by the overhead associated with auto detecting the format. If you specify an explicit load format and it will turn out to be wrong, the auto detection will be invoked and a second attempt to load the file will be made.

MswVersion

Allows to specify that the document loading process should match a specific MS Word version. Default value is Aspose.Words.Settings.MsWordVersion.Word2019

public MsWordVersion MswVersion { get; set; }

Property Value

MsWordVersion

Remarks

Different Word versions may handle certain aspects of document content and formatting slightly differently during the loading process, which may result in minor differences in Document Object Model.

Password

Gets or sets the password for opening an encrypted document. Can be null or empty string. Default is null.

public string Password { get; set; }

Property Value

string

Remarks

You need to know the password to open an encrypted document. If the document is not encrypted, set this to null or empty string.

PreserveIncludePictureField

Gets or sets whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is false.

public bool PreserveIncludePictureField { get; set; }

Property Value

bool

Remarks

By default, the INCLUDEPICTURE field is converted into a shape object. You can override that if you need the field to be preserved, for example, if you wish to update it programmatically. Note however that this approach is not common for Aspose.Words. Use it on your own risk.

One of the possible use cases may be using a MERGEFIELD as a child field to dynamically change the source path of the picture. In this case you need the INCLUDEPICTURE to be preserved in the model.

ProgressCallback

Called during loading a document and accepts data about loading progress.

public IDocumentLoadingCallback ProgressCallback { get; set; }

Property Value

IDocumentLoadingCallback

Remarks

Aspose.Words.LoadFormat.Docx, Aspose.Words.LoadFormat.FlatOpc, Aspose.Words.LoadFormat.Docm, Aspose.Words.LoadFormat.Dotm, Aspose.Words.LoadFormat.Dotx, Aspose.Words.LoadFormat.Markdown, Aspose.Words.LoadFormat.Rtf, Aspose.Words.LoadFormat.WordML, Aspose.Words.LoadFormat.Doc, Aspose.Words.LoadFormat.Dot, Aspose.Words.LoadFormat.Odt, Aspose.Words.LoadFormat.Ott formats supported.

ResourceLoadingCallback

Allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.

public IResourceLoadingCallback ResourceLoadingCallback { get; set; }

Property Value

IResourceLoadingCallback

TempFolder

Allows to use temporary files when reading document. By default this property is null and no temporary files are used.

public string TempFolder { get; set; }

Property Value

string

Remarks

The folder must exist and be writable, otherwise an exception will be thrown.

Aspose.Words automatically deletes all temporary files when reading is complete.

UpdateDirtyFields

Specifies whether to update the fields with the dirty attribute.

public bool UpdateDirtyFields { get; set; }

Property Value

bool

UseSystemLcid

Gets or sets whether to use LCID value obtained from Windows registry to determine page setup default margins.

public bool UseSystemLcid { get; set; }

Property Value

bool

Remarks

If set to true, then MS Word behavior is emulated which takes LCID value from Windows registry.

The default value is false.

WarningCallback

Called during a load operation, when an issue is detected that might result in data or formatting fidelity loss.

public IWarningCallback WarningCallback { get; set; }

Property Value

IWarningCallback

Methods

Equals(object)

Determines whether the specified object is equal in value to the current object.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

 English