Class AnnotationCollection
Collection of annotations attached to a PDF page (spec §12.5).
Use the various Add* factory methods to create annotations.
The collection serializes all annotations into the page's /Annots array
during Save(Stream).
Inheritance
AnnotationCollection
Assembly: DRIT.Pdf.dll
Syntax
public sealed class AnnotationCollection
Properties
All
Gets all annotations in this collection in source order.
Declaration
public IReadOnlyList<Annotation> All { get; }
Property Value
Methods
AddCaret(double, double, double, double)
Add a caret annotation (spec §12.5.11).
Indicates text should be inserted at the specified position.
Declaration
public CaretAnnotation AddCaret(double x, double y, double width, double height)
Parameters
Returns
AddCircle(double, double, double, double)
Add a circle (ellipse) annotation (spec §12.5.7.2).
Declaration
public CircleAnnotation AddCircle(double x, double y, double width, double height)
Parameters
Returns
AddCrossOut(Quad)
Add a strike-out text-markup annotation from a Quad.
Declaration
public TextMarkupAnnotation AddCrossOut(Quad quad)
Parameters
| Type |
Name |
Description |
| Quad |
quad |
|
Returns
AddCrossOut(double, double, double, double)
Add a strike-out text-markup annotation (spec §12.5.10).
Declaration
public TextMarkupAnnotation AddCrossOut(double left, double bottom, double right, double top)
Parameters
Returns
AddEmptyFileAttachment(double, double, string, EmbeddedFileCollection, string?)
Create a new empty embedded file in embeddedFiles and attach it.
Declaration
public FileAttachmentAnnotation AddEmptyFileAttachment(double x, double y, string name, EmbeddedFileCollection embeddedFiles, string? mimeType = null)
Parameters
Returns
AddFileAttachment(PdfPoint, EmbeddedFile)
Add a file-attachment annotation at the given point, referencing an embedded file.
Declaration
public FileAttachmentAnnotation AddFileAttachment(PdfPoint point, EmbeddedFile file)
Parameters
Returns
AddFileAttachment(double, double, EmbeddedFile)
Add a file-attachment annotation at explicit coordinates.
Declaration
public FileAttachmentAnnotation AddFileAttachment(double x, double y, EmbeddedFile file)
Parameters
Returns
AddFreeText(double, double, double, double, string?)
Add a free-text annotation (spec §12.5.6.6).
Displays text directly on the page at the specified rectangle.
Declaration
public FreeTextAnnotation AddFreeText(double x, double y, double width, double height, string? text = null)
Parameters
Returns
AddHighlight(Quad)
Add a highlight text-markup annotation from a Quad.
Declaration
public TextMarkupAnnotation AddHighlight(Quad quad)
Parameters
| Type |
Name |
Description |
| Quad |
quad |
|
Returns
AddHighlight(double, double, double, double)
Add a highlight text-markup annotation (spec §12.5.10).
Declaration
public TextMarkupAnnotation AddHighlight(double left, double bottom, double right, double top)
Parameters
Returns
AddInk(double, double, double, double)
Add an ink (freehand pencil-mark) annotation (spec §12.5.8).
Returns the annotation so the caller can build paths via BeginPath/LineTo.
Declaration
public InkAnnotation AddInk(double x, double y, double width, double height)
Parameters
Returns
AddLine(PdfPoint, PdfPoint)
Add a line annotation with optional measurement metadata (spec §12.5.6.7).
Declaration
public LineAnnotation AddLine(PdfPoint start, PdfPoint end)
Parameters
Returns
AddLine(double, double, double, double)
Add a line annotation at explicit coordinates.
Declaration
public LineAnnotation AddLine(double x1, double y1, double x2, double y2)
Parameters
Returns
AddLink(double, double, double, double)
Add a hyperlink annotation covering the given rectangle in page user-space units.
The origin (x, y) is the bottom-left corner of the rectangle.
Declaration
public LinkAnnotation AddLink(double x, double y, double width, double height)
Parameters
Returns
AddOval(double, double, double, double)
Declaration
public CircleAnnotation AddOval(double x, double y, double width, double height)
Parameters
Returns
AddPencilMark(double, double, double, double)
Add a pencil-mark annotation (alias for ink, spec §12.5.8).
Declaration
public InkAnnotation AddPencilMark(double x, double y, double width, double height)
Parameters
Returns
AddPolygon(params PdfPoint[])
Add a polygon annotation (spec §12.5.6.9). The polygon is automatically closed.
Requires at least three vertices.
Declaration
public PolygonAnnotation AddPolygon(params PdfPoint[] vertices)
Parameters
| Type |
Name |
Description |
| PdfPoint[] |
vertices |
|
Returns
AddPolyline(params PdfPoint[])
Add a polyline annotation with optional measurement metadata (spec §12.5.6.8).
Requires at least two vertices.
Declaration
public PolylineAnnotation AddPolyline(params PdfPoint[] vertices)
Parameters
| Type |
Name |
Description |
| PdfPoint[] |
vertices |
|
Returns
AddRedaction(PdfRect)
Declaration
public void AddRedaction(PdfRect region)
Parameters
| Type |
Name |
Description |
| PdfRect |
region |
|
AddRedaction(double, double, double, double)
Declaration
public RedactionAnnotation AddRedaction(double x, double y, double width, double height)
Parameters
Returns
AddRedactionAnnotation(double, double, double, double)
Add a full redaction annotation (spec §12.5.13) with optional overlay text
and custom interior color.
Declaration
public RedactionAnnotation AddRedactionAnnotation(double x, double y, double width, double height)
Parameters
Returns
AddSquare(double, double, double, double)
Add a square (rectangle) annotation (spec §12.5.7.1).
Declaration
public SquareAnnotation AddSquare(double x, double y, double width, double height)
Parameters
Returns
AddSquare(string?, double, double, double, double)
Add a square annotation with a title (used for markup grouping).
Declaration
public SquareAnnotation AddSquare(string? title, double x, double y, double width, double height)
Parameters
Returns
AddSquiggly(double, double, double, double)
Add a squiggly underline text-markup annotation (spec §12.5.10).
Declaration
public TextMarkupAnnotation AddSquiggly(double left, double bottom, double right, double top)
Parameters
Returns
AddStamp(double, double, double, double, StampIcon)
Add a rubber-stamp annotation (spec §12.5.12).
Displays a standard stamp icon at the specified rectangle.
Declaration
public StampAnnotation AddStamp(double x, double y, double width, double height, StampIcon icon)
Parameters
Returns
AddStickyNote(double, double, string?)
Add a sticky-note (text) annotation (spec §12.5.6.4).
Displays a small icon at the specified position with an optional popup.
Declaration
public StickyNoteAnnotation AddStickyNote(double x, double y, string? contents = null)
Parameters
Returns
AddTextBox(double, double, double, double)
Declaration
public FreeTextAnnotation AddTextBox(double x, double y, double width, double height)
Parameters
Returns
Declaration
public FreeTextAnnotation AddTextComment(double x, double y, double width, double height)
Parameters
Returns
AddUnderline(Quad)
Add an underline text-markup annotation from a Quad.
Declaration
public TextMarkupAnnotation AddUnderline(Quad quad)
Parameters
| Type |
Name |
Description |
| Quad |
quad |
|
Returns
AddUnderline(double, double, double, double)
Add an underline text-markup annotation (spec §12.5.10).
Declaration
public TextMarkupAnnotation AddUnderline(double left, double bottom, double right, double top)
Parameters
Returns
Flatten()
Flattens annotations by removing interactive annotation dictionaries from the page.
Existing static page content is preserved.
Declaration