// 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;
HtmlOptions options = new HtmlOptions();
// Set watermark properties
Watermark watermark = new Watermark(watermarkText);
//Set color for watermark with values Red, Green, Blue and Alpha(Transparency)
Color watermarkColor = new Color(200, 75, 75, 100);
watermark.setColor(watermarkColor);
watermark.setPosition(WatermarkPosition.Diagonal);
watermark.setWidth(100f);
options.setWatermark(watermark);
// Get document pages html representation with watermark
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();
}