GroupDocsGists
10/24/2017 - 1:20 PM

Examples-GroupDocs.Annotation.Examples.Java-src-main-java-GroupDocs-Annotation-Examples-Java-DataStorage-moveAnnotationResult.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);
	IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
	// Create document data object in storage.
	Document document = documentRepository.getDocument(fileName);
	long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
	// Create annotation object
	AnnotationInfo areaAnnotation = new AnnotationInfo();
	areaAnnotation.setAnnotationPosition(new Point(852.0, 271.7));
	areaAnnotation.setBackgroundColor(3355443);
	areaAnnotation.setBox(new Rectangle(466f, 271f, 69f, 62f));
	areaAnnotation.setPageNumber(0);
	areaAnnotation.setPenColor(3355443);
	areaAnnotation.setType(AnnotationType.Area);
	areaAnnotation.setCreatorName("Anonym A.");
	areaAnnotation.setDocumentGuid(documentId);
	// Add annotation to storage
	CreateAnnotationResult createAreaAnnotationResult = annotator.createAnnotation(areaAnnotation);
	// Move annotation marker
	MoveAnnotationResult moveAnnotationResult = annotator.moveAnnotationMarker(
			createAreaAnnotationResult.getId(), new Point(200, 200), /* NewPageNumber */ 1);
	System.out.println(moveAnnotationResult);
	System.out.println(moveAnnotationResult);
	// Check data
	GetAnnotationResult resizedAnnotation = annotator.getAnnotation(createAreaAnnotationResult.getGuid());
	System.out.println(resizedAnnotation);
} catch (Exception e) {
	System.out.println("Exception: " + e.getMessage());
	e.printStackTrace();
}