Specify encoding when loading documents
Leave feedback
You can specify the encoding using LoadOptions.
This feature is supported for the following documents:
- Plain-text (.txt) files
- Comma-separated values (.csv)
- Tab-separated values (.tsv)
- E-Mail Message (.eml)
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);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.