# LinkAnnotation Class

> A link annotation, which features an embedded hyperlink.

- Product: Adobe PDF Library 18
- Language: Java
- Version: APDFL18.0.5PlusP2e
- HTML page: https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation
- Version index: https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/llms.txt

```java
class LinkAnnotation : Annotation
```

**Namespace:** `com::datalogics::PDFL`

**Inherits from:** [`Annotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Annotation.md)

## Description

A link annotation, which features an embedded hyperlink.

**Referenced by:** [`LinkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation.md)

**Uses types:** [`Action`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Action.md), [`Annotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Annotation.md), [`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md), [`Form`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Form.md), [`LinkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation.md), [`OptionalContentContext`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentContext.md), [`OptionalContentMembershipDict`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentMembershipDict.md), [`PDFDict`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFDict.md), [`Page`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Page.md), [`Point`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Point.md), [`Rect`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Rect.md), [`ViewDestination`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ViewDestination.md)

## Constructors

### LinkAnnotation

```java
com.datalogics.PDFL.LinkAnnotation.LinkAnnotation(Page page, Rect initialRect)
```

*constructor*

**Parameters**

- `page` ([`Page`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Page.md)): The page to which the LinkAnnotation is added.
- `initialRect` ([`Rect`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Rect.md)): A rectangle specifying the annotation's bounds, specified in user space coordinates.

Create a new LinkAnnotation at the end of a page's annotation array. To create a LinkAnnotation and place it elsewhere in the page's annotation array, use the version of the constructor that takes an array position.

### LinkAnnotation

```java
com.datalogics.PDFL.LinkAnnotation.LinkAnnotation(Page page, Rect initialRect, int addAfter)
```

*constructor*

**Parameters**

- `page` ([`Page`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Page.md)): The page to which the annotation is added.
- `initialRect` ([`Rect`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Rect.md)): A rectangle specifying the annotation's bounds, specified in user space coordinates.
- `addAfter` (`int`): Where to add the annotation in the page's annotation array. To add the annotation to the end of the array, pass a value of -2 or use the alternate version of this constructor that does not take an index (this is generally what you should do unless you have a need to place the annotation at a special location in the array). Passing a value of -1 adds the annotation to the beginning of the array. Passing other negative values produces undefined results.

Create a new LinkAnnotation at a specific index in the page's annotation array.

## Methods

### copyTo

```java
LinkAnnotation com.datalogics.PDFL.LinkAnnotation.copyTo(Page destination)
```

**Parameters**

- `destination` ([`Page`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Page.md)): the page to copy the annotation to. The page may be in the same document as the source annotation or in a different document.

**Returns:** [`LinkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation.md)

the annotation created on the destination page.

Copy a LinkAnnotation to the specified page. The annotation will be centered on the page. To center the annotation at a specific point, use the version of this method that accepts a Point.

This creates a copy of the original LinkAnnotation and puts the copy in the destination page's annotation dictionary. Structural content information associated with the source annotation will not be present in the copy. An exception will be thrown if the annotation cannot be copied to the specified page.

Note: If copying LinkAnnotations between pages in different documents, the source annotation may have a ViewDestination that's invalid in the destiantion document or an Action referring to a ViewDestination that's invalid in the destination document. In these cases, an exception will be thrown.

### copyTo

```java
LinkAnnotation com.datalogics.PDFL.LinkAnnotation.copyTo(Page destination, Point centerPoint)
```

**Parameters**

- `destination` ([`Page`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Page.md)): the page to copy the annotation to. The page may be in the same document as the source annotation or in a different document.
- `centerPoint` ([`Point`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Point.md)): the point to center the annotation on.

**Returns:** [`LinkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation.md)

the annotation created on the destination page.

Copy a LinkAnnotation to the specified page and center the annotation on the specified point.

This creates a copy of the original LinkAnnotation and puts the copy in the destination page's annotation dictionary. Structural content information associated with the source annotation will not be present in the copy. An exception will be thrown if the annotation cannot be copied to the specified page.

Note: If copying LinkAnnotations between pages in different documents, the source annotation may have a ViewDestination that's invalid in the destiantion document or an Action referring to a ViewDestination that's invalid in the destination document. In these cases, an exception will be thrown.

### delete

```java
synchronized void com.datalogics.PDFL.LinkAnnotation.delete(Boolean disposing)
```

*protected*

**Parameters**

- `disposing` (`Boolean`)

**Returns:** `synchronized void`

### delete

```java
synchronized void com.datalogics.PDFL.LinkAnnotation.delete()
```

**Returns:** `synchronized void`

### equals

```java
boolean com.datalogics.PDFL.Annotation.equals(Object rhs)
```

**Parameters**

- `rhs` (`Object`)

**Returns:** `boolean`

### finalize

```java
void com.datalogics.PDFL.LinkAnnotation.finalize()
```

*protected*

**Returns:** `void`

### generateAppearance

```java
Form com.datalogics.PDFL.LinkAnnotation.generateAppearance()
```

**Returns:** [`Form`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Form.md)

A new Form containing the generated appearance, or null if the appearance could not be generated (for example, due to an invalid border style).

Generate a new appearance stream with the current annotation properties.

The resulting Form can then be used to set the annotation's appearance, such as by calling SetNormalAppearance.

### getAction

```java
Action com.datalogics.PDFL.LinkAnnotation.getAction()
```

**Returns:** [`Action`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Action.md)

The Action object for this link.

Note that setting the Action will wipe out the Link's Destination member a link annotation cannot have both members.

### getAnnotationFeatureLevel

```java
double com.datalogics.PDFL.LinkAnnotation.getAnnotationFeatureLevel()
```

**Returns:** `double`

The minimum PDF version necessary to support the features used in this annotation.

### getBorderStyle

```java
String com.datalogics.PDFL.LinkAnnotation.getBorderStyle()
```

**Returns:** `String`

The border style.

Can be one of:
S - Solid

D - Dashed. The dash pattern is specified as an array (see DashPattern)

B - Beveled

I - Inset

U - Underline

Other border styles may be defined in the future. Default is "S"

### getBorderStyleDashPattern

```java
java.util.List< Double > com.datalogics.PDFL.LinkAnnotation.getBorderStyleDashPattern()
```

**Returns:** `java.util.List< Double >`

An array defining a pattern of dashes and gaps to be used in drawing a dashed border (border style D).

The dash array is a series of numbers that specify the lengths of alternating dashes and gaps. Lengths must be nonnegative, and are expressed in user space units.

Default value is [3]

### getBorderStyleWidth

```java
double com.datalogics.PDFL.LinkAnnotation.getBorderStyleWidth()
```

**Returns:** `double`

The border width in points.

If this value is 0, no border is drawn. The default is 1.0.

### getColor

```java
Color com.datalogics.PDFL.Annotation.getColor()
```

**Returns:** [`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md)

The annotation's color.

The color of the annotation.

### getContents

```java
String com.datalogics.PDFL.Annotation.getContents()
```

**Returns:** `String`

The annotation's text contents.

The text contents of the annotation. The text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation's contents in human-readable form.

### getDestination

```java
ViewDestination com.datalogics.PDFL.LinkAnnotation.getDestination()
```

**Returns:** [`ViewDestination`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ViewDestination.md)

The Destination for this link.

Note that setting the Destination will wipe out the Link's Action member a link annotation cannot have both members.

### getFlags

```java
java.util.EnumSet< AnnotationFlags > com.datalogics.PDFL.Annotation.getFlags()
```

**Returns:** `java.util.EnumSet< AnnotationFlags >`

The annotation's flags.

The flags for the annotation.

### getHighlight

```java
HighlightStyle com.datalogics.PDFL.LinkAnnotation.getHighlight()
```

**Returns:** `HighlightStyle`

The Highlighstyle for this link.

### getInteriorColor

```java
Color com.datalogics.PDFL.Annotation.getInteriorColor()
```

**Returns:** [`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md)

The interior fill color, or null if no interior color is set.

The interior color with which to fill the annotation's rectangle or circle. The color of the border itself can be retrieved from Annotation.Color.

### getNormalAppearance

```java
Form com.datalogics.PDFL.Annotation.getNormalAppearance()
```

**Returns:** [`Form`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Form.md)

A Form representing the annotation's normal appearance, or null if no normal appearance has been set.

The normal appearance of the annotation, represented as a Form XObject.

### getOpacity

```java
double com.datalogics.PDFL.Annotation.getOpacity()
```

**Returns:** `double`

The opacity value for this annotation.

The constant opacity value used in painting a Markup annotation. Opacity is a range from 0.0 (fully transparent) to 1.0 (fully opaque).

### getOptionalContentMembershipDict

```java
OptionalContentMembershipDict com.datalogics.PDFL.Annotation.getOptionalContentMembershipDict()
```

**Returns:** [`OptionalContentMembershipDict`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentMembershipDict.md)

the OptionalContentMembershipDict

The OptionalContentMembershipDict property for this Annotation.

Setting this property will attach the Annotation to an OptionalContentMembershipDict; it will then be associated with the OptionalContentGroups and be subject to the VisibilityPolicy and VisibilityExpression of that MembershipDict.

By setting this property to null, the Annotation is detached from any OptionalContentMembershipDict.

### getPDFDict

```java
PDFDict com.datalogics.PDFL.Annotation.getPDFDict()
```

**Returns:** [`PDFDict`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFDict.md)

The PDFDict associated with this annotation.

The underlying PDF dictionary for this annotation. Retrieves the PDFDict representation of this annotation object.

### getRect

```java
Rect com.datalogics.PDFL.Annotation.getRect()
```

**Returns:** [`Rect`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Rect.md)

The annotation's bounding rectangle in user space coordinates.

The size and location of the annotation on its page.

### getSubtype

```java
String com.datalogics.PDFL.Annotation.getSubtype()
```

**Returns:** `String`

The subtype string (e.g. "Circle", "Square", "Line").

The annotation's subtype.

### getTitle

```java
String com.datalogics.PDFL.Annotation.getTitle()
```

**Returns:** `String`

The title string.

The title of the annotation.

### hasRichTextData

```java
boolean com.datalogics.PDFL.Annotation.hasRichTextData()
```

**Returns:** `boolean`

true if the annotation contains Rich Text String content.

Checks the annotation for Rich Text String content (PDFReference 1.7 Section 8.6.2). Annotations that contain Rich Text String content and do not have a normal appearance set will not be visible when rendering the page.

### isCurrentlyVisible

```java
boolean com.datalogics.PDFL.Annotation.isCurrentlyVisible(OptionalContentContext occ)
```

**Parameters**

- `occ` ([`OptionalContentContext`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentContext.md)): The optional content context in which to check visibility.

**Returns:** `boolean`

true if the annotation is currently visible.

Tests whether an annotation is visible in a given optional content context, considering the current ON-OFF states of the optional-content groups in the optional-content dictionary (OCMD) and the dictionary's visibility policy.

If the annotation occurs more than once within the content, this method only checks the visibility of the first occurrence of the annotation.

This method determines visibility without considering the visbility of the Content object that the annotation belongs to. To determine the visibility of an annotation while taking the Content's visibility into consideration, use the alternate version of this method.

### setAction

```java
void com.datalogics.PDFL.LinkAnnotation.setAction(Action newaction)
```

**Parameters**

- `newaction` ([`Action`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Action.md))

**Returns:** `void`

The Action object for this link.

Note that setting the Action will wipe out the Link's Destination member a link annotation cannot have both members.

### setAnnotationFeatureLevel

```java
void com.datalogics.PDFL.LinkAnnotation.setAnnotationFeatureLevel(double featureLevel)
```

**Parameters**

- `featureLevel` (`double`)

**Returns:** `void`

Removes features not supported in the supplied version number.

### setBorderStyle

```java
void com.datalogics.PDFL.LinkAnnotation.setBorderStyle(String style)
```

**Parameters**

- `style` (`String`)

**Returns:** `void`

The border style.

Can be one of:
S - Solid

D - Dashed. The dash pattern is specified as an array (see DashPattern)

B - Beveled

I - Inset

U - Underline

Other border styles may be defined in the future. Default is "S"

### setBorderStyleDashPattern

```java
void com.datalogics.PDFL.LinkAnnotation.setBorderStyleDashPattern(java.util.List< Double > dashPattern)
```

**Parameters**

- `dashPattern` (`java.util.List< Double >`)

**Returns:** `void`

An array defining a pattern of dashes and gaps to be used in drawing a dashed border (border style D).

The dash array is a series of numbers that specify the lengths of alternating dashes and gaps. Lengths must be nonnegative, and are expressed in user space units.

Default value is [3]

### setBorderStyleWidth

```java
void com.datalogics.PDFL.LinkAnnotation.setBorderStyleWidth(double width)
```

**Parameters**

- `width` (`double`)

**Returns:** `void`

The border width in points.

If this value is 0, no border is drawn. The default is 1.0.

### setColor

```java
void com.datalogics.PDFL.Annotation.setColor(Color color)
```

**Parameters**

- `color` ([`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md)): The new color to set.

**Returns:** `void`

The color of the annotation.

### setContents

```java
void com.datalogics.PDFL.Annotation.setContents(String contents)
```

**Parameters**

- `contents` (`String`): The new text contents.

**Returns:** `void`

The text contents of the annotation. The text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation's contents in human-readable form.

### setDestination

```java
void com.datalogics.PDFL.LinkAnnotation.setDestination(ViewDestination newdest)
```

**Parameters**

- `newdest` ([`ViewDestination`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ViewDestination.md))

**Returns:** `void`

The Destination for this link.

Note that setting the Destination will wipe out the Link's Action member a link annotation cannot have both members.

### setFlags

```java
void com.datalogics.PDFL.Annotation.setFlags(java.util.EnumSet< AnnotationFlags > flags)
```

**Parameters**

- `flags` (`java.util.EnumSet< AnnotationFlags >`): The new annotation flags to set.

**Returns:** `void`

The flags for the annotation.

### setHighlight

```java
void com.datalogics.PDFL.LinkAnnotation.setHighlight(HighlightStyle style)
```

**Parameters**

- `style` (`HighlightStyle`)

**Returns:** `void`

The Highlighstyle for this link.

### setInteriorColor

```java
void com.datalogics.PDFL.Annotation.setInteriorColor(Color color)
```

**Parameters**

- `color` ([`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md)): The new interior fill color. Pass null to remove the interior color.

**Returns:** `void`

The interior color with which to fill the annotation's rectangle or circle. Only RGB colors are allowed.

The color of the border itself can be retrieved from Annotation.Color.

### setNormalAppearance

```java
void com.datalogics.PDFL.Annotation.setNormalAppearance(Form form)
```

**Parameters**

- `form` ([`Form`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Form.md)): The Form to use as the annotation's normal appearance.

**Returns:** `void`

The normal appearance of the annotation, represented as a Form XObject.

### setOpacity

```java
void com.datalogics.PDFL.Annotation.setOpacity(double opacityValue)
```

**Parameters**

- `opacityValue` (`double`): The new opacity value to set.

**Returns:** `void`

The constant opacity value used in painting a Markup annotation. Opacity is a range from 0.0 (fully transparent) to 1.0 (fully opaque).

### setOptionalContentMembershipDict

```java
void com.datalogics.PDFL.Annotation.setOptionalContentMembershipDict(OptionalContentMembershipDict ocmd)
```

**Parameters**

- `ocmd` ([`OptionalContentMembershipDict`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentMembershipDict.md)): the OptionalContentMembershipDict

**Returns:** `void`

The OptionalContentMembershipDict property for this Annotation.

Setting this property will attach the Annotation to an OptionalContentMembershipDict; it will then be associated with the OptionalContentGroups and be subject to the VisibilityPolicy and VisibilityExpression of that MembershipDict.

By setting this property to null, the Annotation is detached from any OptionalContentMembershipDict.

### setRect

```java
void com.datalogics.PDFL.Annotation.setRect(Rect rect)
```

**Parameters**

- `rect` ([`Rect`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Rect.md)): The new bounding rectangle in user space coordinates.

**Returns:** `void`

The size and location of the annotation on its page.

### setTitle

```java
void com.datalogics.PDFL.Annotation.setTitle(String title)
```

**Parameters**

- `title` (`String`): The new title string.

**Returns:** `void`

The title of the annotation.

### toString

```java
String com.datalogics.PDFL.Annotation.toString()
```

**Returns:** `String`

A string describing this annotation, including its type and rectangle.

Returns a string representation of this annotation.
