usmanazizgroupdocs
3/15/2016 - 3:20 PM

RemoveAnnotation.cs

// For complete examples and data files, please go to https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET
// Create instance of annotator. 
AnnotationConfig cfg = CommonUtilities.GetConfiguration();

AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
if (!Directory.Exists(cfg.StoragePath))
{
    Directory.CreateDirectory(cfg.StoragePath);
}

// Create document data object in storage.
var document = documentRepository.GetDocument("Document.pdf");
long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf");

// Create annotation object
AnnotationInfo pointAnnotation = new AnnotationInfo
{
    AnnotationPosition = new Point(852.0, 81.0),
    Box = new Rectangle(212f, 81f, 142f, 0.0f),
    Type = AnnotationType.Point,
    PageNumber = 0,
    CreatorName = "Anonym",
    DocumentGuid = documentId
};

// Get all annotations from storage
ListAnnotationsResult listAnnotationsResult = annotator.GetAnnotations(documentId);

// Get annotation  
var annotation = annotator.GetAnnotation(listAnnotationsResult.Annotations[0].Guid);


// Delete single annotation
var deleteAnnotationResult = annotator.DeleteAnnotation(annotation.Id);

//Delete all annotations
annotator.DeleteAnnotations(documentId);