HtmlLoadOptions

HtmlLoadOptions class

Allows to specify additional options when loading HTML document into a Document object.

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

public class HtmlLoadOptions : LoadOptions

Constructors

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

Properties

NameDescription
BaseUri { get; set; }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.
BlockImportMode { get; set; }Gets or sets a value that specifies how properties of block-level elements are imported. Default value is Merge.
ConvertMetafilesToPng { get; set; }Gets or sets whether to convert metafile(Wmf or Emf) images to Png image format.
ConvertShapeToOfficeMath { get; set; }Gets or sets whether to convert shapes with EquationXML to Office Math objects.
ConvertSvgToEmf { get; set; }Gets or sets a value indicating whether to convert loaded SVG images to the EMF format. Default value is false and, if possible, loaded SVG images are stored as is without conversion.
Encoding { get; set; }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.
FontSettings { get; set; }Allows to specify document font settings.
IgnoreNoscriptElements { get; set; }Gets or sets a value indicating whether to ignore <noscript> HTML elements. Default value is false.
IgnoreOleData { get; set; }Specifies whether to ignore the OLE data.
LanguagePreferences { get; }Gets language preferences that will be used when document is loading.
LoadFormat { get; set; }Specifies the format of the document to be loaded. Default is Auto.
MswVersion { get; set; }Allows to specify that the document loading process should match a specific MS Word version. Default value is Word2019
Password { get; set; }Gets or sets the password for opening an encrypted document. Can be null or empty string. Default is null.
PreferredControlType { get; set; }Gets or sets preferred type of document nodes that will represent imported <input> and <select> elements. Default value is FormField.
PreserveIncludePictureField { get; set; }Gets or sets whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is false.
ProgressCallback { get; set; }Called during loading a document and accepts data about loading progress.
ResourceLoadingCallback { get; set; }Allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.
SupportFontFaceRules { get; set; }Gets or sets a value indicating whether to support @font-face rules and whether to load declared fonts. Default value is false.
SupportVml { get; set; }Gets or sets a value indicating whether to support VML images.
TempFolder { get; set; }Allows to use temporary files when reading document. By default this property is null and no temporary files are used.
UpdateDirtyFields { get; set; }Specifies whether to update the fields with the dirty attribute.
UseSystemLcid { get; set; }Gets or sets whether to use LCID value obtained from Windows registry to determine page setup default margins.
WarningCallback { get; set; }Called during a load operation, when an issue is detected that might result in data or formatting fidelity loss.
WebRequestTimeout { get; set; }The number of milliseconds to wait before the web request times out. The default value is 100000 milliseconds (100 seconds).

Methods

NameDescription
override Equals(object)Determines whether the specified object is equal in value to the current object.

Examples

Shows how to support conditional comments while loading an HTML document.

HtmlLoadOptions loadOptions = new HtmlLoadOptions();

// If the value is true, then we take VML code into account while parsing the loaded document.
loadOptions.SupportVml = supportVml;

// This document contains a JPEG image within "<!--[if gte vml 1]>" tags,
// and a different PNG image within "<![if !vml]>" tags.
// If we set the "SupportVml" flag to "true", then Aspose.Words will load the JPEG.
// If we set this flag to "false", then Aspose.Words will only load the PNG.
Document doc = new Document(MyDir + "VML conditional.htm", loadOptions);

if (supportVml)
    Assert.AreEqual(ImageType.Jpeg, ((Shape)doc.GetChild(NodeType.Shape, 0, true)).ImageData.ImageType);
else
    Assert.AreEqual(ImageType.Png, ((Shape)doc.GetChild(NodeType.Shape, 0, true)).ImageData.ImageType);

See Also