// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
/**
* This method writes input stream to output image file
*
* @param fileName
* name of the output image file
* @param imageFormat
* format of output image file
*/
public static void saveAsImage(String fileName, String imageFormat, InputStream inputStream) {
try {
// Write input stream to output file
ImageIO.write(ImageIO.read(inputStream), imageFormat,
new File(outputImagePath + GetFileNameWithoutExtension(fileName) + "." + imageFormat));
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
}