# Action Class

> When a user clicks a link or bookmark in a PDF, an action occurs, moving the reader to a new location.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.2.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Action
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/llms.txt

```cpp
class Action
```

**Namespace:** `datalogics_interface`

**Derived classes:** [`GoToAction`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/GoToAction.md), [`LaunchAction`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/LaunchAction.md), [`RemoteGoToAction`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/RemoteGoToAction.md), [`URIAction`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/URIAction.md)

## Description

An action can involve moving the reader to a new page in the file, for example.

Also, with a PDF Viewer a PDF file can have an Action that runs automatically when a user opens the file, or reaches a specific page.

Applications can support Actions in custom annotation types they add. Only GoTo and URI Actions are supported; you can only use an Action with the interface to move from one part of a file to another or open an external web page.

**Referenced by:** [`Bookmark`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Bookmark.md), [`LinkAnnotation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/LinkAnnotation.md)

**Uses types:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/PDFDict.md)

## Constructors

### Action

```cpp
datalogics_interface::Action::Action(Action &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`Action &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Action.md))

### Action

```cpp
datalogics_interface::Action::Action(const Document &doc, const std::string &type)
```

*constructor*

**Parameters**

- `doc` ([`const Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Document.md)): The document in which the action is created.
- `type` (`const std::string &`): The string corresponding to the action's subtype.

Creates a new action object.

### ~Action

```cpp
virtual datalogics_interface::Action::~Action()
```

*destructor*

## Methods

### get_pdf_dict

```cpp
PDFDict datalogics_interface::Action::get_pdf_dict()
```

**Returns:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/PDFDict.md)

The underlying PDF dictionary for this Action.

Retrieve the PDFObject representation of this object.

### get_subtype

```cpp
std::string datalogics_interface::Action::get_subtype() const
```

**Returns:** `std::string`

The subtype string for this action, such as "GoTo", "URI", "Launch", or "GoToR".

The action's subtype.

### operator=

```cpp
Action & datalogics_interface::Action::operator=(Action &&) noexcept
```

**Parameters**

- (unnamed) ([`Action &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Action.md))

**Returns:** [`Action &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Action.md)

### operator==

```cpp
bool datalogics_interface::Action::operator==(const Action &other) const
```

**Parameters**

- `other` ([`const Action &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Action.md))

**Returns:** `bool`

true if the two objects refer to the same action, false otherwise.

Two Actions are considered equal if they refer to the same underlying PDF action object.

### to_string

```cpp
std::string datalogics_interface::Action::to_string() const
```

**Returns:** `std::string`

A string describing this Action.

The string includes the action's subtype.

### try_as

```cpp
T * datalogics_interface::Action::try_as()
```

**Parameters**

- (unnamed) (`typename T`)

**Returns:** `T *`

Attempt to downcast this action to a derived type. Returns a pointer to the derived type, or nullptr if the type doesn't match.

### try_as

```cpp
const T * datalogics_interface::Action::try_as() const
```

**Parameters**

- (unnamed) (`typename T`)

**Returns:** `const T *`

Const overload of try_as(). Returns a const pointer, or nullptr.
