Class LinkAnnotation
Creates a clickable link annotation that navigates to a specific page within the same PDF document. Useful for building custom tables of contents, cross-references, and in-document navigation.
// Add a link on page 0 that navigates to page 5:
var link = new LinkAnnotation(pageIndex: 0, destinationPageIndex: 5)
{
X = 50, Y = 700,
Width = 200, Height = 20
};
pdf.Annotations.Add(link);
// Custom TOC link with color:
var tocLink = new LinkAnnotation(0, 3)
{
X = 72, Y = 600,
Width = 300, Height = 16,
Contents = "Chapter 1 - Introduction"
};
pdf.Annotations.Add(tocLink);The link annotation creates an invisible clickable region on the page.
See: https://ironpdf.com/how-to/annotations/
Coordinate note: The Y property sets the bottom edge
of the clickable area using PDF coordinates (origin at bottom-left of page). When positioning
links over existing text using PdfPage.TextChunks, use
BoundingBox.Bottom for Y and Math.Abs(BoundingBox.Top - BoundingBox.Bottom)
for Height.
Implements
Namespace: IronPdf.Annotations
Assembly: IronPdf.dll
Syntax
public class LinkAnnotation : PdfClientAccessor, IAnnotation
Constructors
LinkAnnotation(Int32, Int32)
Creates a link annotation on the specified page that navigates to a destination page. The annotation must be added to the document via Annotations.
Declaration
public LinkAnnotation(int pageIndex, int destinationPageIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | pageIndex | Zero-based index of the page where the link is placed. |
| System.Int32 | destinationPageIndex | Zero-based index of the page to navigate to when clicked. |
LinkAnnotation(Int32, Int32, String)
Creates a link annotation on the specified page that navigates to a destination page, with descriptive text for identification. The annotation must be added to the document via Annotations.
Declaration
public LinkAnnotation(int pageIndex, int destinationPageIndex, string contents)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | pageIndex | Zero-based index of the page where the link is placed. |
| System.Int32 | destinationPageIndex | Zero-based index of the page to navigate to when clicked. |
| System.String | contents | Descriptive text for the link annotation. |
Properties
AnnotationIndex
Annotation index (of a given page)
Declaration
public int AnnotationIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Color
Gets or sets the color of the link annotation border.
Declaration
public Color Color { get; set; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.Color |
Contents
Gets or sets the descriptive text content for this link annotation.
Declaration
public string Contents { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DestinationBottom
Gets or sets the bottom coordinate of the destination position, in points. Used by PageRect.
Declaration
public int DestinationBottom { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
DestinationLeft
Gets or sets the left coordinate of the destination position, in points. Used by PageZoom, PageX, PageRect, and PageBoundsX.
Declaration
public int DestinationLeft { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
DestinationPageIndex
Gets or sets the zero-based page index to navigate to when this link is clicked. Page 1 = index 0, Page 2 = index 1, etc.
Declaration
public int DestinationPageIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | Zero-based destination page index. |
DestinationRight
Gets or sets the right coordinate of the destination position, in points. Used by PageRect.
Declaration
public int DestinationRight { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
DestinationTop
Gets or sets the top coordinate of the destination position, in points. Used by PageZoom, PageY, PageRect, and PageBoundsY.
Declaration
public int DestinationTop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
DestinationType
Gets or sets the destination type that controls how the page is displayed when the link is clicked. Default is Page which fits the entire destination page in the window. Use PageY with DestinationTop to scroll to a specific vertical position, or PageZoom for full control over position and zoom.
Declaration
public BookmarkDestinations DestinationType { get; set; }
Property Value
| Type | Description |
|---|---|
| BookmarkDestinations | Destination type (default: Page). |
DestinationZoom
Gets or sets the zoom level (in percent) for the destination. Used by PageZoom. A value of 0 means inherit the current zoom.
Declaration
public int DestinationZoom { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Height
Gets or sets the height of the clickable link area, in points.
Declaration
public int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Hidden
Gets or sets whether the link annotation is hidden from users.
Declaration
public bool Hidden { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
PageIndex
Gets or sets the zero-based page index where this link annotation is placed. 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). |
Rectangle
Gets or sets the position and size of the clickable link area.
Declaration
public Rectangle Rectangle { get; set; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.Rectangle |
Title
Gets or sets the title of the link annotation.
Declaration
public string Title { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Width
Gets or sets the width of the clickable link area, in points.
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.
When using BoundingBox from text extraction: Use BoundingBox.Left
for this value.
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.
When using BoundingBox from text extraction: Use BoundingBox.Bottom
(not BoundingBox.Top) for this value, since Y defines the bottom edge of the
clickable area and BoundingBox uses the same PDF coordinate system.
var box = textChunk.BoundingBox;
link.Y = (int)box.Bottom; // correct — aligns with text
link.Height = (int)Math.Abs(box.Top - box.Bottom);
// link.Y = (int)box.Top; // wrong — places link above the text
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 link annotation.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |