Remove annotation from document

GroupDocs.Annotation allows you to remove all previously added annotations. To do this, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the SaveOptions class. Set AnnotationTypes = AnnotationType.None.
  3. Call the Save method. Specify the output document path or stream.

Remove annotation using its index

The following code snippet shows how to remove annotation using its index:

using (Annotator annotator = new Annotator("result.xlsx"))
{
	annotator.Remove(0);
	annotator.Save("removed.xlsx");
}

Remove annotation using the object

The following code snippet shows how to remove annotation using the object:

using (Annotator annotator = new Annotator("result.xlsx"))
{
	var tmp = annotator.Get();
	annotator.Remove(tmp[0]);
	annotator.Save("removed.xlsx");
}

Remove annotations using the list of indexes

The following code snippet shows how to remove annotations using list of indexes:

using (Annotator annotator = new Annotator("result.xlsx"))
{
	var idList = new List<int>{1, 2, 3};
	annotator.Remove(idList);
	annotator.Save("removed.xlsx");
}

Remove annotations using the list of objects

The following code snippet shows how to remove some annotations from document using list of objects:

using (Annotator annotator = new Annotator("result.xlsx"))
{
	var tmp = annotator.Get();
	annotator.Remove(tmp);
	annotator.Save("removed.xlsx");
}