Convert to HTML with advanced options

GroupDocs.Conversion provides WebConvertOptions to give you control over conversion result. The following options could be set:

  • FixedLayout controls the HTML generation. If it’s set to true, fixed layout will be used e.g. absolutely positioned HTML element.
  • Zoom specifies the zoom level in percentage. The default value is 100.
  • UsePdf. Sometimes, for better rendering and elements positioning the source document should be converted to PDF first. If this property is set to true, the input firstly is converted to PDF and after that to desired format.

The following code snippet shows how to convert to HTML with advanced options

Note
From v22.12 and greater
using (Converter converter = new Converter("sample.docx"))
{
    WebConvertOptions options = new WebConvertOptions
    {
        PageNumber = 2,
        PagesCount = 1,
        FixedLayout = true
    };
    converter.Convert("converted.html", options);
}
Note
Before v22.12
using (Converter converter = new Converter("sample.docx"))
{
    MarkupConvertOptions options = new MarkupConvertOptions
    {
        PageNumber = 2,
        PagesCount = 1,
        FixedLayout = true
    };
    converter.Convert("converted.html", options);
}

Control page borders visibility

The following code snippet shows how to convert to HTML and control page borders visibility

var source = "sample.docx";
using (var converter = new Converter(source))
{
    var options = new WebConvertOptions
    {
        FixedLayoutShowBorders = false
    };
    converter.Convert("converted.html" , options);
}
Warning
This functionality is introduced in v20.3