---
title: "Export annotation data from PDF in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/annotations/export-pdf/"
md_url: "https://www.nutrient.io/guides/dotnet/annotations/export-pdf.md"
last_updated: "2026-05-14T21:57:26.856Z"
description: "Discover how to export annotations in .NET using XMP and PDF formats. Explore our step-by-step guides for seamless integration and implementation."
---

# Export annotation data from PDFs in C# .NET

### XMP

[XMP](https://www.nutrient.io/guides/dotnet/annotations/export-xmp.md)

### PDF

[PDF](https://www.nutrient.io/guides/dotnet/annotations/export-pdf.md)

To export data from a PDF annotation, follow the steps below:

1. Create a `GdPicturePDF` object.

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

3. Loop through all PDF pages.

4. Select the PDF page from where to get the annotation data with the [`SelectPage` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SelectPage.html).

5. Get the total number of annotations in the PDF document with the [`GetAnnotationCount` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.AnnotationManager~GetAnnotationCount.html).

6. Loop through all annotations.

7. Use a method to get the annotation data and save it to a variable. For more information, refer to the guide on [getting PDF annotation properties](https://www.nutrient.io/guides/dotnet/annotations/get-properties.md).

The following code example gets the index number, type, and contents of all annotations and saves them to a CSV file:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Create a `StringBuilder` variable to store data.
StringBuilder data = new StringBuilder();
// Add headers to the first line.
String[] headers = { "Index", "Annotation Type", "Contents", "Page" };
data.AppendLine(string.Join(";", headers));
// Get the number of pages.
int pageCount = gdpicturePDF.GetPageCount();
// Loop through all pages.
for(int page = 1; page <= pageCount; page++)
{
    // Select a PDF page.
    gdpicturePDF.SelectPage(page);
    int annotCount = gdpicturePDF.GetAnnotationCount();
    // Loop through all annotations.
    for (int i = 0; i < annotCount; i++)
    {
        // Get the current annotation type.
        string annotType = gdpicturePDF.GetAnnotationSubType(i);
        // Get the current annotation contents.
        string annotContents = gdpicturePDF.GetAnnotationContents(i);
        // Add a new line to the `StringBuilder` with the annotation data.
        String[] newLine = { i.ToString(), annotType.ToString(),
            annotContents.ToString(), page.ToString() };
        data.AppendLine(string.Join(";", newLine));
    }
}
// Save the collected data to a CSV file.
String formData = @"C:\temp\output.csv";
File.AppendAllText(formData, data.ToString());

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Create a `StringBuilder` variable to store data.
    Dim data As StringBuilder = New StringBuilder()
    ' Add headers to the first line.
    Dim headers = {"Index", "Annotation Type", "Contents", "Page"}
    data.AppendLine(String.Join(";", headers))
    ' Get the number of pages.
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    ' Loop through all pages.
    For page = 1 To pageCount
        ' Select a PDF page.
        gdpicturePDF.SelectPage(page)
        Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
        ' Loop through all annotations.
        For i = 0 To annotCount - 1
            ' Get the current annotation type.
            Dim annotType As String = gdpicturePDF.GetAnnotationSubType(i)
            ' Get the current annotation contents.
            Dim annotContents As String = gdpicturePDF.GetAnnotationContents(i)
            ' Add a new line to the `StringBuilder` with the annotation data.
            Dim newLine As String() = {i.ToString(), annotType.ToString(), annotContents.ToString(), page.ToString()}
            data.AppendLine(String.Join(";", newLine))
        Next
    Next
    ' Save the collected data to a CSV file.
    Dim formData = "C:\temp\output.csv"
    File.AppendAllText(formData, data.ToString())
End Using

```

#### Used methods

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

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

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

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

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

#### Related topics

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

## Related pages

- [Annotate on images in C# .NET](/guides/dotnet/annotations/annotate-on-images.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)
- [Attach an image to an annotation in C#](/guides/dotnet/annotations/attach-an-image.md)
- [Custom annotations](/guides/dotnet/annotations/custom-annotations.md)
- [Edit PDF annotations in C#](/guides/dotnet/annotations/edit.md)
- [Export XMP annotation data in C# .NET](/guides/dotnet/annotations/export-xmp.md)
- [Flatten PDF annotations in C# .NET](/guides/dotnet/annotations/flatten.md)
- [Import XFDF annotation data to PDFs in C# .NET](/guides/dotnet/annotations/import-xfdf.md)
- [Get PDF annotation properties in C# .NET](/guides/dotnet/annotations/get-properties.md)
- [PDF annotations in C#.NET](/guides/dotnet/annotations.md)
- [Remove PDF annotations in C# .NET](/guides/dotnet/annotations/remove.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)
- [Add PDF actions using C# in form fields](/guides/dotnet/annotations/pdf-actions-support.md)
- [XMP annotations in C# .NET](/guides/dotnet/annotations/xmp-annotations.md)

