AnnotationCollection

AnnotationCollection

Overview

AnnotationCollection is a class in Aspose.PDF FOSS for .NET. Inherits from: IReadOnlyList<Annotation>.

Collection of annotations on a page.

This class provides 35 methods for working with AnnotationCollection objects in .NET programs. Available methods include: Accept, Add, AddCaretAnnotation, AddCircleAnnotation, AddFileAttachmentAnnotation, AddFreeTextAnnotation, AddHighlightAnnotation, AddInkAnnotation, AddLineAnnotation, AddLinkAnnotation, AddPolyLineAnnotation, AddPolygonAnnotation, and 17 additional methods. All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package. Properties: Count, IsReadOnly, IsSynchronized, SyncRoot.

Properties

NameTypeAccessDescription
CountintReadGets the count.
IsReadOnlyboolReadAlways false: callers may add and remove annotations.
IsSynchronizedboolReadAlways false: callers serialise their own access.
SyncRootobjectReadSentinel object for ICollection.SyncRoot-style locking.

Methods

SignatureDescription
AddTextAnnotation(rect: Rectangle, contents: string, title: string?, open: bool)Add a text (sticky note) annotation.
AddFreeTextAnnotation(rect: Rectangle, contents: string, fontName: string?, fontSize: double, color: double[]?)Add a free text annotation (text displayed directly on the page).
AddLinkAnnotation(rect: Rectangle, uri: string)Add a link annotation with a URI action.
AddLinkAnnotation(rect: Rectangle, destinationPage: int, destRect: Rectangle)Add a link annotation with a page destination (for TOC entries).
AddLinkAnnotation(rect: Rectangle, action: PdfAction)Add a link annotation with a custom action.
AddHighlightAnnotation(rect: Rectangle, quadPoints: double[]?, color: double[]?)Add a highlight annotation.
AddUnderlineAnnotation(rect: Rectangle, quadPoints: double[]?, color: double[]?)Add an underline annotation.
AddStrikeOutAnnotation(rect: Rectangle, quadPoints: double[]?, color: double[]?)Add a strikeout annotation.
AddSquareAnnotation(rect: Rectangle, borderColor: double[]?, fillColor: double[]?, lineWidth: double)Add a square (rectangle) annotation.
AddCircleAnnotation(rect: Rectangle, borderColor: double[]?, fillColor: double[]?, lineWidth: double)Add a circle (ellipse) annotation.
AddLineAnnotation(rect: Rectangle, x1: double, y1: double, x2: double, y2: double, color: double[]?, lineWidth: double)Add a line annotation.
AddInkAnnotation(rect: Rectangle, inkPaths: double[][], color: double[]?, lineWidth: double)Add an ink (freehand drawing) annotation.
AddStampAnnotation(rect: Rectangle, contents: string, stampName: string)Add a rubber stamp annotation.
AddCaretAnnotation(rect: Rectangle, contents: string?)Add a caret annotation (insertion point).
AddRedactAnnotation(rect: Rectangle, color: double[]?, overlayText: string?)Add a redaction annotation.
AddFileAttachmentAnnotation(rect: Rectangle, contents: string, fileName: string, fileData: byte[])Add a file attachment annotation.
AddSquigglyAnnotation(rect: Rectangle, quadPoints: double[]?, color: double[]?)Add a squiggly underline annotation.
AddPolygonAnnotation(rect: Rectangle, vertices: double[], borderColor: double[]?, fillColor: double[]?, lineWidth: double)Add a polygon annotation.
AddPolyLineAnnotation(rect: Rectangle, vertices: double[], color: double[]?, lineWidth: double)Add a polyline annotation.
AddPopupAnnotation(rect: Rectangle, open: bool)Add a popup annotation.
AddWatermarkAnnotation(rect: Rectangle, contents: string?)Add a watermark annotation.
Add(wa: WatermarkAnnotation)Add a WatermarkAnnotation object.
Add(annotation: Annotation)Add any annotation that was created programmatically.
Add(annotation: Annotation, considerRotation: bool)Add an annotation, optionally applying the page’s rotation to the annotation’s /Rect entry before insertion.
Clear()Remove every annotation from the collection.
Contains(annotation: Annotation)True when annotation is currently in the collection (matched by reference, then by backing dict).
CopyTo(array: Annotation[], index: int)Copy annotations into array starting at index.
Delete()Remove every annotation from the collection (alias for Clear).
Delete(index: int)Remove the annotation at the given 1-based index.
FindByName(name: string)Find an annotation whose /NM (annotation name) entry matches name.
Remove(annotation: Annotation)Remove the first match of annotation; returns true when an annotation was removed.
Delete(annotation: Annotation)Remove the given annotation from the collection.
RemoveAt(index: int)Remove an annotation at the given index.
GetEnumerator()Iterate annotations on a snapshot of the underlying list so callers can remove annotations (via Delete / RemoveAt) from inside a foreach without tripping the live-collection guard.
Accept(visitor: AnnotationSelector)Walk every annotation in the collection and dispatch it to visitor.

See Also