How to Add and Edit PDF Annotations

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.


Get started with IronPDF!

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer



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.

TipsAll page indexes follow zero-based indexing.

:path=/static-assets/pdf/content-code-examples/how-to/annotation-add-annotation.cs
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
pdf.Annotations.Add(annotation);
pdf.SaveAs("annotation.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

PDF with an Annotation

The annotation in the PDF document above can be viewed with the Chrome browser.


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.

:path=/static-assets/pdf/content-code-examples/how-to/annotation-edit-annotation.cs
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;

pdf.SaveAs("editedAnnotation.pdf");
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

pdf.SaveAs("editedAnnotation.pdf")
$vbLabelText   $csharpLabel

PDF with an Edited Annotation

The annotation in the PDF document above can be viewed with the Chrome browser.


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.

:path=/static-assets/pdf/content-code-examples/how-to/annotation-remove-single-annotation.cs
using IronPdf;

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

// Remove a single annotation with specified index
pdf.Annotations.RemoveAt(1);

pdf.SaveAs("removeSingleAnnotation.pdf");
Imports IronPdf

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

' Remove a single annotation with specified index
pdf.Annotations.RemoveAt(1)

pdf.SaveAs("removeSingleAnnotation.pdf")
$vbLabelText   $csharpLabel

Removed a Single Annotation on PDF

The annotation in the PDF document above can be viewed with the Chrome browser.

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.

:path=/static-assets/pdf/content-code-examples/how-to/annotation-remove-all-annotation.cs
using IronPdf;

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

// Remove all annotaions on a specified page
pdf.Annotations.RemoveAllAnnotationsForPage(0);

// Remove all annotaions on the document
pdf.Annotations.Clear();

pdf.SaveAs("removeAllAnnotation.pdf");
Imports IronPdf

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

' Remove all annotaions on a specified page
pdf.Annotations.RemoveAllAnnotationsForPage(0)

' Remove all annotaions on the document
pdf.Annotations.Clear()

pdf.SaveAs("removeAllAnnotation.pdf")
$vbLabelText   $csharpLabel

Ready to see what else you can do? Check out our tutorial page here: Edit PDFs

Frequently Asked Questions

How can I add annotations to a PDF in C#?

You can add annotations to a PDF in C# by using IronPDF. First, download the C# library for PDF annotations. Load an existing or create a new PDF document, then use the Add method of the Annotations property to insert comments or notes.

How do I edit existing annotations in a PDF using C#?

To edit existing annotations in a PDF using C#, access the annotation collection through IronPDF's Annotations property. Update properties such as Title, Contents, X, and Y with new information to modify the annotations.

What is the process for removing annotations from a PDF using C#?

You can remove annotations from a PDF using IronPDF by employing methods like RemoveAt to delete a specific annotation, RemoveAllAnnotationsForPage to clear all annotations on a page, or Clear to remove all annotations from the document.

Can I view PDF annotations in a web browser?

Yes, annotations added to PDF documents using IronPDF can be viewed in web browsers such as Chrome.

What are the benefits of adding annotations to PDF documents?

Adding annotations to PDF documents with IronPDF enhances collaboration by allowing users to add comments, reminders, or additional information, improving communication and context for shared content.

How can I find documentation for digital signing and encryption services?

Documentation for digital signing, redaction, encryption, and protection services can be found at IronSecureDoc's official documentation page: https://ironsoftware.com/enterprise/securedoc/docs/.

What C# methods are available for managing PDF annotations?

IronPDF offers several C# methods for managing PDF annotations, including Add for adding, RemoveAt for removing specific annotations, and Clear for clearing all annotations.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.