This tutorial contains information on how to delete all comments in PDF in C#. It has details about the resources required to execute the sample code, a list of necessary steps to write the application, and a runnable sample code to delete all comments from PDF in C#. You will also get information about other types of annotations that can be accessed and processed in a similar way as the comments dealt with in this article.
Steps to Remove Comments from PDF in C#
- Set the development environment to add Aspose.PDF for .NET for deleting comments
- Load the source PDF into the Document class object having comments in it for deletion
- Iterate through all the pages of the PDF to test the annotations
- Iterate through all the annotations on each page
- Check if the annotation type is Text and delete it
- Save the resultant PDF having no comments in it
These steps summarize how to remove comments from PDF in C#. The PDF file contains a collection of pages where each page has its own collection of different types of annotations. These steps describe the method to access each annotation and delete if it is of type Text.
Code to Delete All Comments in PDF in C#
This code demonstrates how to delete comments in PDF in C#. The Pages collection is iterated having a collection named Annotations that is further iterated. We check the Text type annotation for deletion however you may select other annotations as well for processing for example color bar, rich media, stamp, widget, movie, sound, link, and highlight to name a few.
This article has guided us on how to remove comments in PDF in C#. If you want to learn the reverse process to add a comment in a PDF file, refer to the article on how to add comments to a PDF using C#.