// 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;
// Perform page reorder
ReorderPageOptions options = new ReorderPageOptions(pageNumber, newPosition);
htmlHandler.reorderPage(guid, options);
// Set image options to include reorder transformations
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.setTransformations(Transformation.Reorder);
// Get html representation of all document pages, including rotate
// transformations
List<PageHtml> pages = htmlHandler.getPages(guid, htmlOptions);
int pageNumberCount = 1;
for (PageHtml page : pages) {
Utilities.saveAsHtml(pageNumberCount + "_" + fileName, page.getHtmlContent());
pageNumberCount++;
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}