# GoToAction Class

> A go-to action can be executed in a PDF document.

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

```cpp
class GoToAction : Action
```

**Namespace:** `datalogics_interface`

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

## Description

A go-to action includes a hyperlink that, when clicked, takes the reader to a different place within the same document.

The action is linked to a bookmark within the document.

A remote go-to action includes a hyperlink that takes the reader to a destination in a separate document.

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

## Constructors

### GoToAction

```cpp
datalogics_interface::GoToAction::GoToAction(Document &doc, const std::string &named_destination)
```

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/Document.md))
- `named_destination` (`const std::string &`)

Create a GoTo action that resolves a named destination at view time. The named destination is looked up in the document's /Names/Dests name tree when the action fires; use NameTree::put(name, dest) (or the equivalent string-keyed put) to register it.

### GoToAction

```cpp
datalogics_interface::GoToAction::GoToAction(GoToAction &&) noexcept=default
```

*constructor*

**Parameters**

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

### GoToAction

```cpp
datalogics_interface::GoToAction::GoToAction(ViewDestination &dest)
```

*constructor*

**Parameters**

- `dest` ([`ViewDestination &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/ViewDestination.md)): The ViewDestination contained in this class.

General constructor

### ~GoToAction

```cpp
datalogics_interface::GoToAction::~GoToAction() override
```

*destructor*

## Methods

### clear_destination

```cpp
void datalogics_interface::GoToAction::clear_destination()
```

**Returns:** `void`

Removes the destination from this action.

### get_destination

```cpp
std::unique_ptr< ViewDestination > datalogics_interface::GoToAction::get_destination() const
```

**Returns:** [`std::unique_ptr< ViewDestination >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/ViewDestination.md)

The ViewDestination for this action.

The ViewDestination that this go-to action navigates to.

### 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
GoToAction & datalogics_interface::GoToAction::operator=(GoToAction &&) noexcept=default
```

**Parameters**

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

**Returns:** [`GoToAction &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/GoToAction.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.

### set_destination

```cpp
void datalogics_interface::GoToAction::set_destination(const ViewDestination &dest)
```

**Parameters**

- `dest` ([`const ViewDestination &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.2.0/class/ViewDestination.md)): The ViewDestination to set, or null to remove.

**Returns:** `void`

Setting the destination to null removes the destination entry from the action dictionary.

### 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.
