Search Results for

    Show / Hide Table of Contents

    Namespace IronPdf.Annotations

    Classes

    LinkAnnotation

    Creates a clickable link annotation that navigates to a specific page within the same PDF document. Useful for building custom tables of contents, cross-references, and in-document navigation.

    // Add a link on page 0 that navigates to page 5:
    var link = new LinkAnnotation(pageIndex: 0, destinationPageIndex: 5)
    {
        X = 50, Y = 700,
        Width = 200, Height = 20
    };
    pdf.Annotations.Add(link);
    
    // Custom TOC link with color:
    var tocLink = new LinkAnnotation(0, 3)
    {
        X = 72, Y = 600,
        Width = 300, Height = 16,
        Contents = "Chapter 1 - Introduction"
    };
    pdf.Annotations.Add(tocLink);

    The link annotation creates an invisible clickable region on the page.

    See: https://ironpdf.com/how-to/annotations/

    Coordinate note: The Y property sets the bottom edge

    of the clickable area using PDF coordinates (origin at bottom-left of page). When positioning

    links over existing text using PdfPage.TextChunks, use BoundingBox.Bottom for Y and Math.Abs(BoundingBox.Top - BoundingBox.Bottom) for Height.

    PdfAnnotation

    Base PDF annotation

    PdfAnnotationCollection

    Manages the collection of annotations (sticky notes, comments) in a PDF document. Supports adding, removing, and iterating through annotations across all pages.

    Access via Annotations property. Changes to the collection are automatically synchronized with the PDF document.

    Example - Work with annotations:

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

    // Add annotation to first page: var note = new TextAnnotation(0) { Title = "Review Note", Contents = "Please verify this section", X = 100, Y = 700 }; pdf.Annotations.Add(note);

    // List all annotations: foreach (var annotation in pdf.Annotations) Console.WriteLine($"Page {annotation.PageIndex}: {annotation.Contents}");

    // Remove annotations from page 2: pdf.Annotations.RemoveAllAnnotationsForPage(1);

    // Clear all annotations: pdf.Annotations.Clear();

    pdf.SaveAs("annotated.pdf");

    PdfAnnotationType

    PdfFreeTextAnnotation

    PDF free annotation

    PdfLinkAnnotation

    PDF link annotation

    PdfTextAnnotation

    PDF text annotation

    PdfUnknownAnnotation

    An annotation whose subtype has no dedicated representation, for example a form-field Widget. Only the common annotation fields (Type, Rectangle, Color, Name, Contents, Hidden) are populated. Returning this rather than throwing lets callers that enumerate a page's annotations, such as the page-numbered Table of Contents scan, safely ignore subtypes they do not handle.

    TextAnnotation

    Creates interactive sticky-note annotations for PDF documents - like Post-it® notes for digital documents. Perfect for comments, review feedback, and collaborative document workflows.

    // Add simple comment:
    var comment = new TextAnnotation(0, "Review", "Please check figures") {
        X = 100, Y = 100,
        Color = Color.Yellow
    };
    pdf.Annotations.Add(comment);
    
    // Review annotation with metadata:
    var review = new TextAnnotation(pageIndex: 0) {
        Title = "John Smith",
        Subject = "Technical Review",
        Contents = "Algorithm needs optimization",
        X = 300, Y = 500,
        Color = Color.Red,
        OpenByDefault = true
    };
    pdf.Annotations.Add(review);
    
    // Hidden annotation for metadata:
    var metadata = new TextAnnotation(0, "Version", "v2.1.0") {
        Hidden = true,
        Printable = false
    };
    pdf.Annotations.Add(metadata);

    Annotations appear as icons that expand to show full text

    Some PDF viewers may not respect all properties

    See: https://ironpdf.com/how-to/annotations/

    TextAnnotation.AnnotationIcon

    Icons used to interact with (open/close) the annotation with the PDF page.

    Interfaces

    IAnnotation

    PDF document annotation

    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget