// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Options to convert 1, 3, 5, 6, 8 page numbers
HtmlOptions options = new HtmlOptions();
options.setPageNumbersToConvert(listPagesToConvert);
List<PageHtml> pages = htmlHandler.getPages(guid, options);
for (PageHtml page : pages) {
Utilities.saveAsHtml(page.getPageNumber() + "_" + fileName, page.getHtmlContent());
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}