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.
ExecuteScriptsWhether the document’s scripts run while it loads and converts. Default: false. Available since version 26.10.
ExternalResourceHandlerA handler called for each resource the document asks to load; it can allow the resource, skip it or supply its content. Default: null. Available since version 26.10.
PageNumberingWhether to generate page numbers for the converted document. Default: false.
ResourceLoadingTimeoutSpecifies the timeout of loading the external resources.
SkipExternalResourcesWhether to skip the external resources the document references. Default: true. Content the document carries, local files inside its folder and resources that match WhitelistedResources still load.
WhitelistedResourcesAbsolute URI prefixes, such as https://cdn.example.com/assets/, of external resources to load while SkipExternalResources is true. Since version 26.10, an entry that is not an absolute URI prefix makes the load fail with InvalidLoadOptionsException.

Enable page numbering when converting to Word-processing formats

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

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);
}

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.

External resources are not loaded by default, and scripts do not run. Read the Skip loading of external resources article to learn how to allow trusted resources, decide per resource with a handler and run scripts with GroupDocs.Conversion for .NET.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.