Add or Remove Annotations in PDF Files using C#

Add or Remove Annotation in PDF

PDF annotations are the additional objects used to mark up the content in PDFs. Since PDF files are not easily editable, the annotations are used to add notes about the content. The PDF annotations include comments, popups, and various other graphical objects. In this article, you will learn how to work with PDF annotations programmatically. Particularly, we will cover how to add and remove annotations in PDF files using C#.

C# API to Add PDF Annotations – Free Download

In order to work with PDF documents from within your .NET applications, Aspose provides Aspose.PDF for .NET. Using the API, you can create new as well as manipulate existing PDF files seamlessly. Furthermore, the API also allows you to add and remove PDF annotations. You can either download the API or install it within your .NET applications using NuGet.

PM> Install-Package Aspose.Pdf

Add Annotations to PDF using C#

PDF format supports various types of annotations such as text, line, circle, square, redaction and etc. In order to work with each PDF annotation, Aspose.PDF for .NET provides separate classes. For example, LineAnnotation class is used for adding a line whereas HighlightAnnotation class is used to add a highlight annotation. Let’s have a look at the steps of adding any type of annotation to a PDF.

Steps to Add Annotation in PDF using C#

For demonstration, the following code sample shows how to add a line annotation to the PDF using C#.

For the code samples of other annotation types, you can visit the following documentation articles:

Remove Annotations from PDF in C#

You can also remove the PDF annotations from existing PDF documents using Aspose.PDF for .NET. You can either remove all or a particular annotation from a PDF. The following are the steps to remove PDF annotations.

The following code sample shows how to remove annotations from a PDF file using C#.

Conclusion

PDF annotations are used to annotate the documents in order to insert text, graphics, and multimedia objects. Furthermore, the annotations help you add additional information or explanation about the content. In accordance with that, this article covered how to add and remove annotations from PDF using C#. In case you want to explore more about working with PDF annotations, visit documentation.

See Also