Load Markup document with options

GroupDocs.Conversion provides WebLoadOptions to give you control over how the source markup document will be processed. The following options could be set:

OptionDescription
BasePathSpecifies the base path/url for the HTML.
EncodingSpecifies the encoding to be used to load the document. If not specified, the encoding will be determined from the document’s character set attribute.
PageNumberingWhether to generate page numbers for the converted document. Default: false.
ResourceLoadingTimeoutSpecifies the timeout of loading the external resources.
SkipExternalResourcesIf enabled, the external resources (except for those listed in WhitelistedResources) will not be loaded during the conversion.
WhitelistedResourcesSpecifies which external resources will be loaded even when the loading of other external resources is restricted.

Enable page numbering when converting to Word-processing formats

The following code snippet shows how to convert a markup document and insert page numbering:

With v24.10 and later:

var source = "sample.html";
var loadOptions = new WebLoadOptions
{
    PageNumbering = true
};
using (var converter = new Converter(source, (LoadContext loadContext) => loadOptions))
{
    var options = new WordProcessingConvertOptions();
    converter.Convert("converted.docx" , options);
}

Before v24.10:

var source = "sample.html";
var loadOptions = new WebLoadOptions
{
    PageNumbering = true
};
using (var converter = new Converter(source, () => loadOptions))
{
    var options = new WordProcessingConvertOptions();
    converter.Convert("converted.docx" , options);
}

Skip loading of external resources

External resources in the context of web documents refer to any files or data that a web page or website fetches from sources outside of its own domain or server. These external resources are essential for creating dynamic and feature-rich web experiences. Common external resources include images, audio, video, fonts, CSS, scripts, frameworks, and so on.

In some cases, you may want to skip loading all or just some of the external resources during the conversion. For example, when these resources become unavailable. Read the Skip loading of external resources article to learn how to do this with GroupDocs.Conversion for .NET.