---
title: "PDF annotation actions on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/annotations/pdf-actions/"
md_url: "https://www.nutrient.io/guides/android/annotations/pdf-actions.md"
last_updated: "2026-05-23T00:08:17.983Z"
description: "PDF annotation actions on Android | guide for Nutrient Android SDK with detailed instructions and code examples."
---

# PDF annotation actions on Android

A PDF action is similar to a web hyperlink, but it’s much more flexible. Nutrient supports most common actions defined in Adobe’s PDF Reference (page 417ff).

The most common types are GoTo and URI. However, many documents also use named actions for page changes.

Every [`Action`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-action/index.html) subclass can be parsed from a PDF:

| Action     | Nutrient class         | Use case                                               |
| ---------- | ---------------------- | ------------------------------------------------------ |
| GoTo       | [`GoToAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-go-to-action/index.html)       | Go to a destination (page) in the current document.    |
| URI        | [`UriAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-uri-action/index.html)        | Resolve a uniform resource identifier (web link).      |
| Hide       | [`HideAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-hide-action/index.html)       | Set an annotation’s hidden flag.                       |
| Named      | [`NamedAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-named-action/index.html)      | Execute an action predefined by the conforming reader. |
| SubmitForm | [`SubmitFormAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-submit-form-action/index.html) | Submit form data.                                      |
| ResetForm  | [`ResetFormAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-reset-form-action/index.html)  | Set fields to their default values.                    |
| JavaScript | [`JavaScriptAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-java-script-action/index.html) | Execute a [JavaScript](https://www.nutrient.io/guides/android/features/javascript.md) script.                       |

Actions are chainable via the [`getSubActions`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-action/sub-actions.html) property. Certain annotations, such as the [`LinkAnnotation`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations/-link-annotation/index.html) and the [`WidgetAnnotation`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations/-widget-annotation/index.html), can contain an action. An [`OutlineElement`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-outline-element/index.html) also contains an [`action`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-action/index.html); as such, it supports the same types of actions as an annotation (for example, a PDF outline can open a web link).

## Trigger events

[`WidgetAnnotation`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations/-widget-annotation/index.html) can contain a set of additional actions on top of the standard action described above. Each of these additional actions is tied to a specific [`AnnotationTriggerEvent`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-annotation-trigger-event/index.html).

All trigger events can be parsed from a PDF. However, Nutrient only supports action execution for a subset of these events (unsupported events are ignored):

| Event            | Use case                                                                                                                                                                                       |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MOUSE_DOWN`     | Action to be executed when touching down on an annotation.                                                                                                                                     |
| `MOUSE_UP`       | Action to be executed when touching up after a successful tap gesture on an annotation.                                                                                                        |
| `RECEIVE_FOCUS`  | Action to be executed when an annotation gets selected.                                                                                                                                        |
| `LOOSE_FOCUS`    | Action to be executed when an annotation gets deselected.                                                                                                                                      |
| `FORM_CHANGED`   | A JavaScript action to be executed when a user types a keystroke into text or combo box fields or modifies selected options in list box fields. The action can reject or modify the keystroke. |
| `FIELD_FORMAT`   | A JavaScript action to be executed before the form field is formatted.                                                                                                                         |
| `FORM_VALIDATE`  | A JavaScript action to be executed when the form field’s value is changed. This is used to check whether the new value is valid.                                                               |
| `FORM_CALCULATE` | A JavaScript action to be executed to recalculate the value of this form field when another field changes.                                                                                     |

To stay backward compatible with older PDF specifications, Nutrient will give annotation actions returned by [`getAction()`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations/-link-annotation/get-action.html) precedence over an additional `MOUSE_UP` action.

Trigger events specific to form fields (`FORM_CHANGED`, `FIELD_FORMAT`, `FORM_VALIDATE`, and `FORM_CALCULATE`) only support [`JavaScriptAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-java-script-action/index.html).

## Executing actions

You can use [`PdfFragment#executeAction`] to execute PDF actions:

### KOTLIN

```kotlin

annotation.action?.let { action ->
  fragment.executeAction(action)
}

```

### JAVA

```java

if (annotation.getAction()!= null) {
  fragment.executeAction(annotation.getAction());
}

```

You can also provide an optional [`ActionSender`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-action-sender/index.html) to inform the action executor about the context in which it should execute the action:

### KOTLIN

```kotlin

formElement.annotation.action?.let { action ->
  fragment.executeAction(action, ActionSender(formElement))
}

```

### JAVA

```java

WidgetAnnotation annotation = formElement.getAnnotation();
if (annotation.action!= null) {
  fragment.executeAction(annotation.action, new ActionSender(formElement));
}

```

You **must** provide [`ActionSender`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-action-sender/index.html) when executing [`JavaScriptAction`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.annotations.actions/-java-script-action/index.html). This way, you’ll provide the correct execution context to the action executor. If you don’t provide the action sender in this case, your JavaScript scripts will be executed as document-level scripts instead. This means that you won’t be able to format or validate form fields, nor will you be able to access form fields or annotations via the `this` object in your scripts.

The file structure for the action has to be correctly specified for it to work. The files in question should be in a local folder.
---

## Related pages

- [Add link annotations to PDFs on Android](/guides/android/annotations/link-annotations.md)

