DEV Community

IronSoftware
IronSoftware

Posted on

PDF Annotations in C# (.NET Guide)

PDF annotations are sticky notes, highlights, and comments attached to specific locations in a document. They're essential for document review workflows—letting reviewers mark up PDFs without altering the original content.

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("document.pdf");

var annotation = new PdfAnnotation(0, 100, 100)
{
    Title = "Review Note",
    Contents = "Please verify this section.",
    Icon = PdfAnnotationIcon.Comment
};

pdf.Annotations.Add(annotation);
pdf.SaveAs("annotated.pdf");
Enter fullscreen mode Exit fullscreen mode

IronPDF makes adding annotations straightforward—just specify where and what to say.

What Types of Annotations Can I Add?

PDF annotations come in several varieties:

Type Purpose
Text (Sticky Note) Comments anchored to a point
Highlight Mark up existing text
Underline Emphasize text
Strikeout Mark text for deletion
Link Clickable navigation
Stamp Visual markers (Approved, Draft, etc.)

IronPDF's PdfAnnotation class handles text annotations. For stamps and visual elements, use the stamping features.

How Do I Add a Text Annotation?

Text annotations appear as icons that expand when clicked:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("contract.pdf");

// Create annotation at position (200, 300) on page 0
var annotation = new PdfAnnotation(
    pageIndex: 0,
    x: 200,
    y: 300)
{
    Title = "Legal Review",
    Contents = "This clause needs revision. See comments from legal team.",
    Icon = PdfAnnotationIcon.Comment,
    Opacity = 0.9,
    Printable = true,
    Hidden = false,
    Open = false  // Collapsed by default
};

pdf.Annotations.Add(annotation);
pdf.SaveAs("contract-reviewed.pdf");
Enter fullscreen mode Exit fullscreen mode

Coordinates are in points (72 points = 1 inch) from the bottom-left corner.

What Annotation Icons Are Available?

IronPDF supports standard PDF annotation icons:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("document.pdf");

// Different icon types for different purposes
var comment = new PdfAnnotation(0, 100, 700)
{
    Title = "Comment",
    Contents = "General feedback",
    Icon = PdfAnnotationIcon.Comment
};

var help = new PdfAnnotation(0, 150, 700)
{
    Title = "Question",
    Contents = "Clarification needed here",
    Icon = PdfAnnotationIcon.Help
};

var note = new PdfAnnotation(0, 200, 700)
{
    Title = "Note",
    Contents = "Important information",
    Icon = PdfAnnotationIcon.Note
};

var insert = new PdfAnnotation(0, 250, 700)
{
    Title = "Insert",
    Contents = "Add text here",
    Icon = PdfAnnotationIcon.Insert
};

pdf.Annotations.Add(comment);
pdf.Annotations.Add(help);
pdf.Annotations.Add(note);
pdf.Annotations.Add(insert);

pdf.SaveAs("multi-annotated.pdf");
Enter fullscreen mode Exit fullscreen mode

Icons provide visual cues about the annotation's purpose.

How Do I Control Annotation Appearance?

Customize color, opacity, and visibility:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("report.pdf");

var annotation = new PdfAnnotation(0, 300, 500)
{
    Title = "Important",
    Contents = "This data requires verification",
    Icon = PdfAnnotationIcon.Note,

    // Appearance settings
    Opacity = 0.75,           // 75% opaque
    Printable = true,         // Show when printed
    Hidden = false,           // Visible on screen
    Open = true,              // Expanded by default
    ReadOnly = false,         // Can be edited
    Subject = "Data Review"   // Category/subject
};

pdf.Annotations.Add(annotation);
pdf.SaveAs("styled-annotation.pdf");
Enter fullscreen mode Exit fullscreen mode

The Printable property is useful—sometimes you want annotations visible on screen but not in printed copies.

How Do I Read Existing Annotations?

Retrieve annotations from a PDF:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("annotated-document.pdf");

// Get all annotations
var annotations = pdf.Annotations;

Console.WriteLine($"Found {annotations.Count} annotations");

foreach (var annotation in annotations)
{
    Console.WriteLine($"Page: {annotation.PageIndex}");
    Console.WriteLine($"Title: {annotation.Title}");
    Console.WriteLine($"Contents: {annotation.Contents}");
    Console.WriteLine($"Position: ({annotation.X}, {annotation.Y})");
    Console.WriteLine("---");
}
Enter fullscreen mode Exit fullscreen mode

Useful for extracting review comments or generating annotation reports.

How Do I Edit Annotations?

Modify existing annotations:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("reviewed.pdf");

// Get annotations
var annotations = pdf.Annotations;

// Edit first annotation
if (annotations.Count > 0)
{
    var first = annotations[0];
    first.Contents = "Updated: This issue has been resolved.";
    first.Title = "Resolved";
}

// Edit all annotations matching criteria
foreach (var annotation in annotations)
{
    if (annotation.Title == "Review Note")
    {
        annotation.Title = "Addressed";
        annotation.Contents += "\n[Status: Complete]";
    }
}

pdf.SaveAs("updated-annotations.pdf");
Enter fullscreen mode Exit fullscreen mode

How Do I Remove Annotations?

Delete specific or all annotations:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("annotated.pdf");

// Remove a specific annotation by index
pdf.Annotations.RemoveAt(0);

// Or remove all annotations
pdf.Annotations.Clear();

pdf.SaveAs("clean.pdf");
Enter fullscreen mode Exit fullscreen mode

For selective removal:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("document.pdf");

// Remove annotations by criteria
var toRemove = pdf.Annotations
    .Where(a => a.Title == "Draft" || a.PageIndex == 0)
    .ToList();

foreach (var annotation in toRemove)
{
    pdf.Annotations.Remove(annotation);
}

pdf.SaveAs("filtered.pdf");
Enter fullscreen mode Exit fullscreen mode

How Do I Add Annotations to Specific Pages?

Target annotations to particular pages:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("multipage.pdf");

// Annotation on first page (index 0)
pdf.Annotations.Add(new PdfAnnotation(0, 100, 700)
{
    Title = "Introduction",
    Contents = "Good overview"
});

// Annotation on third page (index 2)
pdf.Annotations.Add(new PdfAnnotation(2, 100, 700)
{
    Title = "Analysis",
    Contents = "Numbers need verification"
});

// Annotation on last page
int lastPage = pdf.PageCount - 1;
pdf.Annotations.Add(new PdfAnnotation(lastPage, 100, 700)
{
    Title = "Conclusion",
    Contents = "Strong summary"
});

pdf.SaveAs("page-annotated.pdf");
Enter fullscreen mode Exit fullscreen mode

How Do I Create a Document Review Workflow?

Build a practical review system:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

public class DocumentReviewer
{
    public void AddReviewComment(PdfDocument pdf, int page,
        double x, double y, string reviewer, string comment)
    {
        var annotation = new PdfAnnotation(page, x, y)
        {
            Title = $"Review by {reviewer}",
            Contents = comment,
            Icon = PdfAnnotationIcon.Comment,
            Subject = "Review Comment",
            Printable = false  // Don't print review comments
        };

        pdf.Annotations.Add(annotation);
    }

    public void MarkAsApproved(PdfDocument pdf, int page)
    {
        var approval = new PdfAnnotation(page, 450, 750)
        {
            Title = "Status",
            Contents = $"Approved on {DateTime.Now:yyyy-MM-dd}",
            Icon = PdfAnnotationIcon.Check,
            Printable = true
        };

        pdf.Annotations.Add(approval);
    }

    public List<string> GetAllComments(PdfDocument pdf)
    {
        return pdf.Annotations
            .Where(a => a.Subject == "Review Comment")
            .Select(a => $"Page {a.PageIndex + 1}: {a.Contents}")
            .ToList();
    }
}

// Usage
var pdf = PdfDocument.FromFile("draft.pdf");
var reviewer = new DocumentReviewer();

reviewer.AddReviewComment(pdf, 0, 200, 500, "John", "Good introduction");
reviewer.AddReviewComment(pdf, 2, 150, 400, "Jane", "Check these figures");
reviewer.MarkAsApproved(pdf, pdf.PageCount - 1);

pdf.SaveAs("reviewed-draft.pdf");
Enter fullscreen mode Exit fullscreen mode

How Do I Export Annotations?

Extract annotations for external processing:

using IronPdf;
using System.Text.Json;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("reviewed.pdf");

var exportData = pdf.Annotations.Select(a => new
{
    Page = a.PageIndex + 1,
    Position = new { X = a.X, Y = a.Y },
    Title = a.Title,
    Content = a.Contents,
    Subject = a.Subject
}).ToList();

var json = JsonSerializer.Serialize(exportData, new JsonSerializerOptions
{
    WriteIndented = true
});

File.WriteAllText("annotations.json", json);
Console.WriteLine($"Exported {exportData.Count} annotations");
Enter fullscreen mode Exit fullscreen mode

How Do I Add Annotations During PDF Creation?

Add annotations while generating PDFs:

using IronPdf;
// Install via NuGet: Install-Package IronPdf

var renderer = new [ChromePdfRenderer](https://ironpdf.com/blog/videos/how-to-render-webgl-sites-to-pdf-in-csharp-ironpdf/)();
var pdf = renderer.RenderHtmlAsPdf(@"
    <h1>Project Proposal</h1>
    <p>This document outlines the project scope...</p>
    <h2>Budget</h2>
    <p>Total estimated cost: $50,000</p>
");

// Add annotations to the freshly created PDF
pdf.Annotations.Add(new PdfAnnotation(0, 100, 600)
{
    Title = "Author Note",
    Contents = "Budget figures are preliminary estimates",
    Icon = PdfAnnotationIcon.Note
});

pdf.SaveAs("proposal-with-notes.pdf");
Enter fullscreen mode Exit fullscreen mode

Quick Reference

Operation Code
Add annotation pdf.Annotations.Add(new PdfAnnotation(...))
Get count pdf.Annotations.Count
Access by index pdf.Annotations[0]
Remove specific pdf.Annotations.RemoveAt(index)
Remove all pdf.Annotations.Clear()
Iterate foreach (var a in pdf.Annotations)
Property Purpose
PageIndex Which page (0-based)
X, Y Position in points
Title Annotation header
Contents Main text
Icon Visual icon type
Opacity Transparency (0-1)
Printable Include when printing
Open Expanded by default

PDF annotations transform static documents into collaborative review tools. Add them programmatically to automate document workflows.

For more annotation options, see the IronPDF annotations documentation.


Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads a team of 50+ engineers building .NET document processing libraries.

Top comments (0)