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
getBasePath()Specifies the base path/url for the HTML.
getEncoding()Specifies the encoding to be used to load the document. If not specified, the encoding will be determined from the document’s character set attribute.
isPageNumbering()Whether to generate page numbers for the converted document. Default: false.
getResourceLoadingTimeout()Specifies the timeout of loading the external resources.
getSkipExternalResources()If enabled, the external resources (except for those listed in WhitelistedResources) will not be loaded during the conversion.
getWhitelistedResources()Specifies 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:

Note
From v22.12 and greater

    WebLoadOptions loadOptions = new WebLoadOptions();
    loadOptions.setPageNumbering(true);

    Converter converter = new Converter("sample.html", () -> loadOptions);

    WordProcessingConvertOptions options = new WordProcessingConvertOptions();
    converter.convert("converted.docx" , options);
Note
Before v22.12

    MarkupLoadOptions loadOptions = new MarkupLoadOptions();
    loadOptions.setPageNumbering(true);

    Converter converter = new Converter("sample.html", () -> loadOptions);

    WordProcessingConvertOptions options = new WordProcessingConvertOptions();
    converter.convert("converted.docx" , options);
Warning
This functionality is introduced in v20.3

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 Java.