---
title: "Edit PDF annotations in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/annotations/edit/"
md_url: "https://www.nutrient.io/guides/dotnet/annotations/edit.md"
last_updated: "2026-05-21T17:12:02.199Z"
description: "Learn how to edit existing annotations within PDF documents programmatically in C# using Nutrient .NET SDK. Modify comments, highlights, and other markups in your PDFs."
---

# Edit PDF annotations in C#

To edit an annotation, use one of the methods starting with the `SetAnnotation` prefix. All these methods require the annotation index as their parameter. Any additional parameters depend on the method you want to use. These methods can change the following areas of an annotation, among others:

- Appearance

- Content

- Function properties

To edit an annotation, follow these steps:

1. Create a `GdPicturePDF` object.

2. Load a PDF file with the [`LoadFromFile` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~LoadFromFile.html).

3. Select the PDF page where the searched annotation is located.

4. Loop through all the annotations on the selected page. Use the [`GetAnnotationCount` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~GetAnnotationCount.html) to get the total amount of annotations on the selected page.

5. Determine the searched annotation by any of its parameters, such as its title, type, or subject. Use the methods starting with the `GetAnnotation` prefix. The full list is available in the [get properties](https://www.nutrient.io/guides/dotnet/annotations/get-properties.md) guide.

6. Modify the annotation with a method starting with the `SetAnnotation` prefix.

7. Save the PDF document to a file with the [`SaveToFile` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SaveToFile.html).

If you want to edit an annotation you just created, save the return value of the method used to create the annotation, which is the annotation index.

To change the content of a free text annotation, use the following code:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Select the PDF page.
gdpicturePDF.SelectPage(1);
// Get the annotation count.
int annotCount = gdpicturePDF.GetAnnotationCount();
// Loop through all annotations.
for (int i = 0; i < annotCount; i++)
{
    // Check if the current annotation is of the `FreeText` type.
    if (gdpicturePDF.GetAnnotationSubType(i) == "FreeText")
    {
        // Change the annotation content.
        gdpicturePDF.SetAnnotationContents(i, "New content");
    }
}
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Select the PDF page.
    gdpicturePDF.SelectPage(1)
    ' Get the annotation count.
    Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
    ' Loop through all annotations.
    For i = 0 To annotCount - 1
        ' Check if the current annotation is of the `FreeText` type.
        If gdpicturePDF.GetAnnotationSubType(i) Is "FreeText" Then
            ' Change the annotation content.
            gdpicturePDF.SetAnnotationContents(i, "New content")
        End If
    Next
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`GetAnnotationCount`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~GetAnnotationCount.html)

- [`GetAnnotationSubType`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~GetAnnotationSubType.html)

- [`LoadFromFile`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`SaveToFile`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SaveToFile.html)

- [`SelectPage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SelectPage.html)

- [`SetAnnotationContents`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetAnnotationContents.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [Custom annotations](/guides/dotnet/annotations/custom-annotations.md)
- [Annotate on images in C# .NET](/guides/dotnet/annotations/annotate-on-images.md)
- [Attach an image to an annotation in C#](/guides/dotnet/annotations/attach-an-image.md)
- [Attach a file to an annotation in C#](/guides/dotnet/annotations/attach-a-file.md)
- [Create an annotation in a PDF using C#](/guides/dotnet/annotations/create.md)
- [Export XMP annotation data in C# .NET](/guides/dotnet/annotations/export-xmp.md)
- [Export annotation data from PDFs in C# .NET](/guides/dotnet/annotations/export-pdf.md)
- [Flatten PDF annotations in C# .NET](/guides/dotnet/annotations/flatten.md)
- [Get PDF annotation properties in C# .NET](/guides/dotnet/annotations/get-properties.md)
- [Import XFDF annotation data to PDFs in C# .NET](/guides/dotnet/annotations/import-xfdf.md)
- [Remove PDF annotations in C# .NET](/guides/dotnet/annotations/remove.md)
- [PDF annotations in C#.NET](/guides/dotnet/annotations.md)
- [Add PDF actions using C# in form fields](/guides/dotnet/annotations/pdf-actions-support.md)
- [Import XMP annotation data to PDF or image in C#](/guides/dotnet/annotations/import-xmp.md)
- [Stamp a PDF document in C# .NET](/guides/dotnet/annotations/stamp-a-document.md)
- [XMP annotations in C# .NET](/guides/dotnet/annotations/xmp-annotations.md)

