Add or Remove Annotations in PDF Files using C#

Add or Remove Annotation in PDF

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

C# API to Work with PDF Annotations – Free Download

In order to work with PDF documents from within your .NET applications, Aspose provides Aspose.PDF for .NET. The API lets you create new as well as manipulate existing PDF files seamlessly. It also allows you to add and remove PDF annotations within a few lines of code. 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 in a PDF document.

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. The annotations help you add additional information or explanation about the content. This article provides simple ways of adding and removing annotations from PDF documents using C#. You can explore more about the PDF annotations using documentation.

See Also