Search Results for

    Show / Hide Table of Contents

    Class 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");

    Inheritance
    System.Object
    PdfAnnotationCollection
    Namespace: IronPdf.Annotations
    Assembly: IronPdf.dll
    Syntax
    public class PdfAnnotationCollection : ObservableCollection<IAnnotation>
    Remarks

    Supported Operations:

    Related Resources:

    Methods

    ClearItems()

    Override Clear() with Interop RemoveAnnotation() through every annotations in the collection.

    Declaration
    protected override void ClearItems()

    RemoveAllAnnotationsForPage(Int32)

    Removes all annotations from a specific page of the PDF document.

    Example:

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

    // Remove annotations from all pages: for (int i = 0; i < pdf.PageCount; i++) pdf.Annotations.RemoveAllAnnotationsForPage(i);

    Declaration
    public void RemoveAllAnnotationsForPage(int pageIndex)
    Parameters
    Type Name Description
    System.Int32 pageIndex

    Zero-based page index (Page 1 = index 0).

    See Also

    TextAnnotation
    Annotations
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronPDF to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronPDF free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.