Class 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/
Implements
Namespace: IronPdf.Annotations
Assembly: IronPdf.dll
Syntax
public class TextAnnotation : PdfClientAccessor, IAnnotation
Constructors
TextAnnotation(Int32)
Define a new annotation with the specified parameters. Annotation must be added to the document via PdfDocument.Annotations
Declaration
public TextAnnotation(int PageIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | PageIndex | Page index |
TextAnnotation(Int32, String, String)
Define a new annotation with the specified parameters. Annotation must be added to the document via PdfDocument.Annotations
Declaration
public TextAnnotation(int PageIndex, string Title, string Contents)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | PageIndex | Page index |
| System.String | Title | Annotation title |
| System.String | Contents | Annotation contents |
TextAnnotation(String, String)
Define a new annotation with the specified parameters. Annotation must be added to the document via PdfDocument.Annotations
Declaration
public TextAnnotation(string Title, string Contents)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | Title | Annotation title |
| System.String | Contents | Annotation contents |
Properties
AnnotationIndex
Gets or sets the zero-based index of this annotation on its page. Used internally to identify the annotation. Value of -1 indicates not yet added to document.
Declaration
public int AnnotationIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | Annotation index, or -1 if not added to document. |
Color
The color of the annotation's 'Sticky Note'
Note: Google Chrome PDF Viewer may not respect this color.
However, Adobe PDF Viewer and Foxit PDF Viewer display the color correctly.
Declaration
public Color Color { get; set; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.Color |
Contents
The contents of the 'sticky note' annotation
Declaration
public string Contents { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Height
Annotation visible height
Note: Google Chrome or Adobe PDF Viewer may not respect this height.
However, Foxit PDF Viewer handles the height correctly.
Declaration
public int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Hidden
Hides the annotation from users
Declaration
public bool Hidden { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Opacity
The opacity of the annotation (valid values are from 0.0 to 1.0)
Declaration
public double Opacity { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
OpenByDefault
Sets the annotation to be opened and readable by default, without user interaction
Declaration
public bool OpenByDefault { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
PageIndex
Gets or sets the zero-based page index where this annotation appears. Page 1 = index 0, Page 2 = index 1, etc. (default: 0 - first page).
Declaration
public int PageIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | Zero-based page index (default: 0). |
Printable
Allows the annotation to be printed when users print the PDF
Declaration
public bool Printable { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ReadOnly
Allows the annotation to be printed when users print the PDF
Declaration
public bool ReadOnly { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Rectangle
The position and size of annotation.
Note: Google Chrome or Adobe PDF Viewer may not respect the width and height.
However, Foxit PDF Viewer handles the position and size correctly.
Declaration
public Rectangle Rectangle { get; set; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.Rectangle |
Rotatable
Allows the annotation to be rotated. E.g. when the containing page os rotated
Declaration
public bool Rotatable { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Subject
The sub title of the annotation as displayed in the header of the 'sticky note'
Declaration
public string Subject { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Title
The main title of the annotation as displayed in the header of the 'sticky note'
Declaration
public string Title { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Width
Annotation visible width
Note: Google Chrome or Adobe PDF Viewer may not respect this width.
However, Foxit PDF Viewer handles the width correctly.
Declaration
public int Width { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
X
Gets or sets the horizontal X position from the LEFT edge of the page, in points. 72 points = 1 inch. Example: X = 72 positions annotation 1 inch from left edge.
Example:
annotation.X = 100; // 100 points from left edge
Declaration
public int X { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | Horizontal position in points from left edge (default: -1 if not set). |
Y
Gets or sets the vertical Y position from the BOTTOM edge of the page, in points. 72 points = 1 inch. PDF coordinate system places Y=0 at bottom of page.
Example:
// Position annotation 2 inches from bottom:
annotation.Y = 144; // 144 points = 2 inches
// Top of an 11-inch page (Letter size):
annotation.Y = 792; // 11 × 72 = 792 points
Declaration
public int Y { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | Vertical position in points from bottom edge (default: -1 if not set). |
Methods
ToString()
Returns a System.String that represents this annotation.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |