GroupDocsGists
10/24/2017 - 1:18 PM

Examples-GroupDocs.Annotation.Examples.Java-src-main-java-GroupDocs-Annotation-Examples-Java-AnnotateDocuments-addAnnotationInCells.java

// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java
try {
	AnnotationConfig cfg = Utilities.getConfiguration();
	AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
	InputStream inputStream = new FileInputStream(Utilities.storagePath + File.separator + fileName);
	List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
	// Add bookmark to 3rd cell in 3rd row on 1st page
	final AnnotationInfo annotationInfo = new AnnotationInfo();
	annotationInfo.setPageNumber(1);
	annotationInfo.setAnnotationPosition(new Point(3, 3));
	annotationInfo.setFieldText("Hello!");
	annotations.add(annotationInfo);
	// Export annotations to Cells document
	InputStream resultStream = annotator.exportAnnotationsToDocument(inputStream, annotations);
	System.out.println(resultStream.available());
	IOUtils.copy(resultStream,
			new FileOutputStream(Utilities.outputPath + File.separator + "cells-annotated.xlsx"));
} catch (Exception e) {
	System.out.println("Exception: " + e.getMessage());
	e.printStackTrace();
}