Annotations are commonly used in documents for pointing out different observations and providing feedback for discussion. We discussed in separate articles, how to add different annotations to PDF and Word documents using C#. Today, this article discusses how to remove annotations from documents like PDF and Word DOC/DOCX files using C#.

The following topics are discussed below:

.NET API for Annotations

GroupDocs.Annotation provides the .NET API to deal with annotations within various documents and images. It allows adding, removal, and extraction of annotations from PDF, Word, and many other documents. You can have a look at the documentation for the complete list of supported document formats for annotation.

Download its DLLs or MSI installer from the downloads section or install the API in your .NET application via NuGet. You may also use the following command from the Package Manager.

PM> Install-Package GroupDocs.Annotation

Remove All Annotations from PDF, Word documents using C#

There are various ways to remove annotations from documents. You can remove all the annotations at once, remove specific annotation(s) by providing ID(s), or remove specific annotation by annotation object. For more options, visit the documentation article.

The following are the steps to remove all the annotations from PDF or Word DOC/DOCX document(s) using C#.

  • Load the document using Annotator.
  • Initialize Saving Options class.
  • Set the annotation type to None.
  • Save the file, free of annotations using the Save() method.

The following code shows how to remove annotations from PDF or Word files using C#.

Remove Annotation by IDs using C#

Similarly, you can provide annotation ID(s) to eliminate these annotations from the document. Just provide the ID or list of IDs to get rid of the specified annotation. The following code shows how to remove the annotation(s) from PDF or Word documents by providing the ID(s) using C#.

Remove Annotation by Annotation Object using C#

You can also get rid of the specific annotation by proving the Annotation object. In order to show this, the following code example removes the annotation(s) from PDF or Word documents by using annotation objects in C#.

Conclusion

To conclude, you have learned how to remove annotations from the documents using C#. Specifically, we removed all the annotations from PDF & Word files. Later we removed annotations by providing IDs and also by proving the annotation objects.

Build your own document annotation remover .NET application using GroupDocs.Annotation for .NET. Learn more about the API from the documentation and the GitHub repository. For further queries, contact the support on the forum.

See Also