GroupDocsGists
10/24/2017 - 1:18 PM

Examples-GroupDocs.Annotation.Examples.Java-src-main-java-GroupDocs-Annotation-Examples-Java-Utilities-getImageRepresentation.java

// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
try {
	InputStream document = new FileInputStream(storagePath + File.separator + fileName);
	AnnotationConfig cfg = getConfiguration();
	AnnotationImageHandler annotationHandler = new AnnotationImageHandler(cfg);
	List<PageImage> images = annotationHandler.getPages(document, new ImageOptions());
	// Save result stream to file.
	OutputStream outputStream = new FileOutputStream(Utilities.outputPath + File.separator + "image.png");
	final PageImage pageImage = images.get(0);
	IOUtils.copy(pageImage.getStream(), outputStream);
	System.out.println("Document exported!");
} catch (Exception e) {
	System.out.println("Exception: " + e.getMessage());
	e.printStackTrace();
}