Specify encoding when loading documents

You can specify the encoding using LoadOptions.

This feature is supported for the following documents:

The following code snippet shows how to specify the document encoding:

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
import com.groupdocs.viewer.options.LoadOptions;
// ...

// Specify an encoding.
LoadOptions loadOptions = new LoadOptions();
loadOptions.setCharset(Charset.forName("windows-1251"));

// Render a file.
try (Viewer viewer = new Viewer("sample.txt", loadOptions)) {
    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
    viewer.view(viewOptions);
}