• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

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
object
AnnotationCollection
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: DRIT.Pdf.Annotations
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
Type Description
IReadOnlyList<Annotation>

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
CaretAnnotation

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
CircleAnnotation

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
Type Description
TextMarkupAnnotation

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
Type Name Description
double left
double bottom
double right
double top
Returns
Type Description
TextMarkupAnnotation

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
Type Name Description
double x
double y
string name
EmbeddedFileCollection embeddedFiles
string mimeType
Returns
Type Description
FileAttachmentAnnotation

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
Type Name Description
PdfPoint point
EmbeddedFile file
Returns
Type Description
FileAttachmentAnnotation

AddFileAttachment(double, double, EmbeddedFile)

Add a file-attachment annotation at explicit coordinates.

Declaration
public FileAttachmentAnnotation AddFileAttachment(double x, double y, EmbeddedFile file)
Parameters
Type Name Description
double x
double y
EmbeddedFile file
Returns
Type Description
FileAttachmentAnnotation

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
Type Name Description
double x
double y
double width
double height
string text
Returns
Type Description
FreeTextAnnotation

AddHighlight(Quad)

Add a highlight text-markup annotation from a Quad.

Declaration
public TextMarkupAnnotation AddHighlight(Quad quad)
Parameters
Type Name Description
Quad quad
Returns
Type Description
TextMarkupAnnotation

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
Type Name Description
double left
double bottom
double right
double top
Returns
Type Description
TextMarkupAnnotation

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
InkAnnotation

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
Type Name Description
PdfPoint start
PdfPoint end
Returns
Type Description
LineAnnotation

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
Type Name Description
double x1
double y1
double x2
double y2
Returns
Type Description
LineAnnotation

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
LinkAnnotation

AddOval(double, double, double, double)

Add an oval (circle) annotation — alias for AddCircle(double, double, double, double).

Declaration
public CircleAnnotation AddOval(double x, double y, double width, double height)
Parameters
Type Name Description
double x
double y
double width
double height
Returns
Type Description
CircleAnnotation

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
InkAnnotation

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
Type Description
PolygonAnnotation

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
Type Description
PolylineAnnotation

AddRedaction(PdfRect)

Mark the given region for redaction (spec §12.5.13). Call ApplyRedactions() before saving to paint solid rectangles over the areas. This method adds a legacy redaction region (simple rectangle). For full redaction annotation support, use AddRedactionAnnotation(double, double, double, double).

Declaration
public void AddRedaction(PdfRect region)
Parameters
Type Name Description
PdfRect region

AddRedaction(double, double, double, double)

Add a redaction annotation from explicit coordinates. Alias for AddRedactionAnnotation(double, double, double, double).

Declaration
public RedactionAnnotation AddRedaction(double x, double y, double width, double height)
Parameters
Type Name Description
double x
double y
double width
double height
Returns
Type Description
RedactionAnnotation

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
RedactionAnnotation

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
Type Name Description
double x
double y
double width
double height
Returns
Type Description
SquareAnnotation

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
Type Name Description
string title
double x
double y
double width
double height
Returns
Type Description
SquareAnnotation

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
Type Name Description
double left
double bottom
double right
double top
Returns
Type Description
TextMarkupAnnotation

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
Type Name Description
double x
double y
double width
double height
StampIcon icon
Returns
Type Description
StampAnnotation

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
Type Name Description
double x
double y
string contents
Returns
Type Description
StickyNoteAnnotation

AddTextBox(double, double, double, double)

Add a text box (free-text) annotation — alias for AddFreeText(double, double, double, double, string?).

Declaration
public FreeTextAnnotation AddTextBox(double x, double y, double width, double height)
Parameters
Type Name Description
double x
double y
double width
double height
Returns
Type Description
FreeTextAnnotation

AddTextComment(double, double, double, double)

Add a text comment (free-text) annotation — alias for AddFreeText(double, double, double, double, string?).

Declaration
public FreeTextAnnotation AddTextComment(double x, double y, double width, double height)
Parameters
Type Name Description
double x
double y
double width
double height
Returns
Type Description
FreeTextAnnotation

AddUnderline(Quad)

Add an underline text-markup annotation from a Quad.

Declaration
public TextMarkupAnnotation AddUnderline(Quad quad)
Parameters
Type Name Description
Quad quad
Returns
Type Description
TextMarkupAnnotation

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
Type Name Description
double left
double bottom
double right
double top
Returns
Type Description
TextMarkupAnnotation

Flatten()

Flattens annotations by removing interactive annotation dictionaries from the page. Existing static page content is preserved.

Declaration
public void Flatten()
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX