// 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);
PdfFileOptions options = new PdfFileOptions();
options.setGuid(fileName);
RotatePageOptions rotateOptions = new RotatePageOptions(1, 90);
imageHandler.rotatePage(fileName, rotateOptions);
// Set apply rotate and reorder transformations
options.setTransformations(Transformation.Rotate);
Watermark watermark = new Watermark("Watermark text.");
watermark.setColor(Color.blue);
watermark.setPosition(WatermarkPosition.Diagonal);
watermark.setWidth(100f);
options.setWatermark(watermark);
// Get file as pdf with transformations
FileContainer container = imageHandler.getPdfFile(options);
// Save file
Utilities.saveAsFile(fileName, container.getStream(), ".pdf");
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}