Remove Annotations from PDF using C#

This article explains how to remove annotations from PDF using C#. It provides the IDE settings, a list of steps, and a sample code for developing a PDF annotation remover using C#. You will learn to filter the annotations before deleting them using various criteria.

Steps to Delete Annotations from PDF using C#

  1. Set the environment to use Aspose.PDF for .NET to remove annotations
  2. Load the source PDF file into the Document object having annotations
  3. Access the collection of the pages and get a reference to the first page
  4. Get access to the collection of the annotations and call the Delete() method
  5. Save the resultant PDF file after deleting the annotations

The above steps describe how to delete annotation in PDF using C#. Load the source PDF file, access the collection of pages, get the target page reference, and get the collection of the annotations. Finally, call the Delete() method to delete all the annotations from the selected page.

Code to Remove All Annotations from PDF using C#

This sample code demonstrates how to remove PDF annotations using C#. You can filter the annotation based on type such as Text, Circle, Polygon, PolyLine, Highlight, Strikeout, and Stamp to list a few names. You can iterate through all the pages in the PDF and delete all the annotations from the entire PDF file.

This short tutorial has taught us how to remove various types of annotations. If you want to add annotations such as comments, refer to the article on How to add comments to a PDF using C#.

 English