usmanazizgroupdocs
4/15/2016 - 10:34 AM

GetDocumentHtmlForPrintWithWatermark.java

// 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 image handler
	ViewerImageHandler imageHandler = new ViewerImageHandler(config);
	String guid = fileName;

	// Set watermark properties
	Watermark watermark = new Watermark(watermarkText);
	watermark.setColor(Color.BLUE);
	watermark.setPosition(WatermarkPosition.Diagonal);
	watermark.setWidth(100f);
	// Get document html for print with watermark
	PrintableHtmlOptions options = new PrintableHtmlOptions(guid, watermark);
	PrintableHtmlContainer container = imageHandler.getPrintableHtml(options);

	// Save as html
	Utilities.saveAsHtml(fileName, container.getHtmlContent());
} catch (Exception exp) {
	System.out.println("Exception: " + exp.getMessage());
	exp.printStackTrace();
}