public class LinkAnnotation extends Object
Mirrors IronPdf.Annotations.LinkAnnotation on the C# side.
// Add a link on page 0 that navigates to page 5:
LinkAnnotation link = new LinkAnnotation(0, 5);
link.setX(50);
link.setY(700);
link.setWidth(200);
link.setHeight(20);
pdf.getAnnotation().addLinkAnnotation(link);
// Custom TOC link with contents text:
LinkAnnotation tocLink = new LinkAnnotation(0, 3, "Chapter 1 - Introduction");
tocLink.setX(72);
tocLink.setY(600);
tocLink.setWidth(300);
tocLink.setHeight(16);
pdf.getAnnotation().addLinkAnnotation(tocLink);
The link annotation creates a clickable region on the page. By default the region is
invisible — set setShowBorder(boolean) to true for a visible border.
Coordinate note: setY(int) sets the bottom edge of the clickable
area using PDF coordinates (origin at bottom-left of page).
| Constructor and Description |
|---|
LinkAnnotation(int pageIndex,
int destinationPageIndex)
Creates a link annotation on the specified page that navigates to a destination page.
|
LinkAnnotation(int pageIndex,
int destinationPageIndex,
String contents)
Creates a link annotation on the specified page that navigates to a destination page,
with descriptive text for identification.
|
public LinkAnnotation(int pageIndex,
int destinationPageIndex)
pageIndex - Zero-based index of the page where the link is placed.destinationPageIndex - Zero-based index of the page to navigate to when clicked.public LinkAnnotation(int pageIndex,
int destinationPageIndex,
String contents)
pageIndex - Zero-based index of the page where the link is placed.destinationPageIndex - Zero-based index of the page to navigate to when clicked.contents - Descriptive text for the link annotation.public int getPageIndex()
public void setPageIndex(int pageIndex)
pageIndex - zero-based page index where this link annotation is placedpublic int getDestinationPageIndex()
public void setDestinationPageIndex(int destinationPageIndex)
destinationPageIndex - zero-based page index this link navigates to when clickedpublic BookmarkDestinations getDestinationType()
public void setDestinationType(BookmarkDestinations destinationType)
destinationType - destination type controlling how the target page is displayedpublic int getDestinationLeft()
public void setDestinationLeft(int destinationLeft)
public int getDestinationRight()
public void setDestinationRight(int destinationRight)
public int getDestinationTop()
public void setDestinationTop(int destinationTop)
public int getDestinationBottom()
public void setDestinationBottom(int destinationBottom)
public int getDestinationZoom()
public void setDestinationZoom(int destinationZoom)
public int getAnnotationIndex()
public void setAnnotationIndex(int annotationIndex)
public int getX()
public void setX(int x)
public int getY()
public void setY(int y)
public int getWidth()
public void setWidth(int width)
public int getHeight()
public void setHeight(int height)
public Rectangle getRectangle()
public void setRectangle(Rectangle rectangle)
public String getColorCode()
#RRGGBB format) or nullpublic void setColorCode(String colorCode)
colorCode - color code for the link border (CSS #RRGGBB format) or nullpublic boolean isHidden()
public void setHidden(boolean hidden)
public String getContents()
public void setContents(String contents)
public String getTitle()
public void setTitle(String title)
public boolean isShowBorder()
false)public void setShowBorder(boolean showBorder)
Copyright © 2022–2026 Iron Software. All rights reserved.