Remove annotation from document

GroupDocs.Annotation provides an ability to remove all previously added annotations from document and save cleaned document as it was before annotating.
There are the steps to remove annotations from document:

  • Instantiate Annotator object with input document path or stream;
  • Instantiate SaveOptions object and set AnnotationTypes = AnnotationType.None;
  • Call Save method with resultant document path or stream and SaveOptions object;
  1. Following code demonstrates how to remove annotation from document using annotation index:
using (Annotator annotator = new Annotator("result.xlsx"))
{
	annotator.Remove(0);
	annotator.Save("removed.xlsx");
}
  1. Following code demonstrates how to remove annotation from document using annotation Object:
using (Annotator annotator = new Annotator("result.xlsx"))
{
	var tmp = annotator.Get();
	annotator.Remove(tmp[0]);
	annotator.Save("removed.xlsx");
}
  1. Following code demonstrates how to remove some annotations from document using list of Id’s:
using (Annotator annotator = new Annotator("result.xlsx"))
{
	var idList = new List<int>{1, 2, 3};
	annotator.Remove(idList);
	annotator.Save("removed.xlsx");
}

4) Following code demonstrates how to remove some annotations from document using list of annotations:

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

More resources

Advanced Usage Topics

To learn more about document annotating features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.