How to Add and Edit PDF Annotations

by Chaknith Bin

Annotations allow users to add comments, reminders, or additional information to specific sections of the document. They enhance collaboration and communication in working with PDFs, enabling users to annotate, comment on, and provide context for shared content.

C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf

Download DLL

Download DLL

Manually install into your project

Add Annotations Example

PDF annotations allow the addition of "sticky note"-like comments to PDF pages. By using the Add method of the Annotations property, annotations can be programmatically added.

All page indexes follow zero-based indexing.

using IronPdf;
using IronPdf.Annotations;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>");

// Create a PDF annotation object on a specified page index
TextAnnotation annotation = new TextAnnotation(0)
    Title = "This is the title",
    Contents = "This is the long 'sticky note' comment content...",
    X = 50,
    Y = 700,

// Add the annotation
VB   C#

PDF with an Annotation

Retrieve and Edit Annotations Example

Retrieving and editing PDF annotations improves collaboration by enhancing clarity, accuracy, and usability. Access the annotation collection through the Annotations property and update properties such as Title, Contents, X, Y, and more with new information.

using IronPdf;
using IronPdf.Annotations;
using System.Linq;

PdfDocument pdf = PdfDocument.FromFile("annotation.pdf");

// Retrieve annotation collection
PdfAnnotationCollection annotationCollection = pdf.Annotations;

// Select the first annotation
TextAnnotation annotation = (TextAnnotation)annotationCollection.First();

// Edit annotation
annotation.Title = "New title";
annotation.Contents = "New content...";
annotation.X = 150;
annotation.Y = 800;

Imports IronPdf
Imports IronPdf.Annotations
Imports System.Linq

Private pdf As PdfDocument = PdfDocument.FromFile("annotation.pdf")

' Retrieve annotation collection
Private annotationCollection As PdfAnnotationCollection = pdf.Annotations

' Select the first annotation
Private annotation As TextAnnotation = CType(annotationCollection.First(), TextAnnotation)

' Edit annotation
annotation.Title = "New title"
annotation.Contents = "New content..."
annotation.X = 150
annotation.Y = 800

VB   C#

PDF with an Edited Annotation

Remove Annotation Example

Easily remove unnecessary or outdated annotations using the following methods: RemoveAt, RemoveAllAnnotationsForPage, and Clear.

  • RemoveAt: Remove a single annotation with a specified index.
  • RemoveAllAnnotationsForPage: Remove all annotations on a specified page.
  • Clear: Remove all annotations in the document.

Remove a Single Annotation

To remove a single annotation, use the RemoveAt method with the corresponding index based on the annotation collection index.

using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");

// Remove a single annotation with specified index

Imports IronPdf

Private pdf As PdfDocument = PdfDocument.FromFile("multipleAnnotation.pdf")

' Remove a single annotation with specified index

VB   C#

Removed a Single Annotation on PDF

Remove All Annotations

To remove all annotations on a particular page, use the RemoveAllAnnotationsForPage method and specify the page index. If you want to remove all annotations in the entire document, simply call the Clear method on the Annotations property of the PdfDocument object.

using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");

// Remove all annotaions on a specified page

// Remove all annotaions on the document

Imports IronPdf

Private pdf As PdfDocument = PdfDocument.FromFile("multipleAnnotation.pdf")

' Remove all annotaions on a specified page

' Remove all annotaions on the document

VB   C#

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.