usmanazizgroupdocs
4/15/2016 - 10:33 AM

PerformMultipleTransformationsInHtmlMode.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 html handler
	ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
	String guid = fileName;

	RotatePageOptions rotatePage = new RotatePageOptions(rotationPageNumber, rotationAngle);
	// Rotate page
	htmlHandler.rotatePage(guid, rotatePage);

	RotatePageOptions rotatePageOp = new RotatePageOptions(2, 180);
	// Rotate second page 180 degrees
	htmlHandler.rotatePage(guid, rotatePageOp);
	ReorderPageOptions reorderPageOp = new ReorderPageOptions(reorderPageNumber, reorderNewPosition);
	// Reorder pages
	htmlHandler.reorderPage(guid, reorderPageOp);

	// Set options to include rotate and reorder transformations
	HtmlOptions options = new HtmlOptions();
	options.setTransformations(
			Transformation.from(Transformation.Rotate, Transformation.Reorder));

	// Set watermark properties
	Watermark watermark = new Watermark("This is watermark text");
	watermark.setColor(Color.BLUE);
	watermark.setPosition(WatermarkPosition.Diagonal);
	watermark.setWidth(100f);

	options.setWatermark(watermark);

	// Get document pages html representation with multiple
	// transformations
	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();
}