# LaunchAction Class

> A launch action launches an application or opens or prints a document.

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

```cpp
class LaunchAction : Action
```

**Namespace:** `datalogics_interface`

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

## Description

A launch action launches an application or opens or prints a document.

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

## Constructors

### LaunchAction

```cpp
datalogics_interface::LaunchAction::LaunchAction(FileSpecification &file_spec)
```

*constructor*

**Parameters**

- `file_spec` ([`FileSpecification &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/FileSpecification.md)): A FileSpecification representing the application to be launched or the document to be opened or printed by this action.

General constructor.

The action's target will be the path referenced in the FileSpecification parameter. If the path is absolute, the target path will also be absolute. If the path is relative, the target path will also be relative.

Generally, the FileSpecification should be associated with the same Document that contains the LaunchAction. (Both FileSpecification and LaunchAction objects are associated with a Document at creation time, and the association cannot be changed.) The LaunchAction will be associated with the same Document that the FileSpecification parameter is associated with.

If the action's FileSpecification is changed during program execution such that the FileSpecification is associated with a different Document than the LaunchAction, saving the Document that contains the action will create a copy of the FileSpecification in the Document that contains the action.

### LaunchAction

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

*constructor*

**Parameters**

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

### ~LaunchAction

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

*destructor*

## Methods

### clear_file_specification

```cpp
void datalogics_interface::LaunchAction::clear_file_specification()
```

**Returns:** `void`

Removes the file specification from this action.

### get_file_specification

```cpp
std::unique_ptr< FileSpecification > datalogics_interface::LaunchAction::get_file_specification() const
```

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

The FileSpecification associated with the LaunchAction.

The FileSpecification for this action.

Generally, the FileSpecification should be associated with the same Document that contains the LaunchAction. (Both FileSpecification and LaunchAction are associated with a Document at creation time.)

### get_new_window

```cpp
bool datalogics_interface::LaunchAction::get_new_window() const
```

**Returns:** `bool`

true if the destination document is set to open in a new window, false otherwise.

Whether the destination document should be opened in a new window.

By default, this flag is not present.

If the action's FileSpecification is not a PDF, this flag is ignored.

### get_pdf_dict

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

**Returns:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.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
LaunchAction & datalogics_interface::LaunchAction::operator=(LaunchAction &&) noexcept=default
```

**Parameters**

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

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

### operator==

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

**Parameters**

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

**Returns:** `bool`

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

Determines whether this Action is equal to another.

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

### set_file_specification

```cpp
void datalogics_interface::LaunchAction::set_file_specification(const FileSpecification &file_spec)
```

**Parameters**

- `file_spec` ([`const FileSpecification &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/FileSpecification.md)): The FileSpecification to associate with the LaunchAction.

**Returns:** `void`

Set the FileSpecification for this action.

Generally, the FileSpecification should be associated with the same Document that contains the LaunchAction. (Both FileSpecification and LaunchAction are associated with a Document at creation time.)

If the FileSpecification is associated with a different Document than the LaunchAction, saving the Document that contains the action will create a copy of the FileSpecification in that Document.

### set_new_window

```cpp
void datalogics_interface::LaunchAction::set_new_window(bool new_window)
```

**Parameters**

- `new_window` (`bool`): true to open the destination document in a new window, false otherwise.

**Returns:** `void`

Set whether the destination document should be opened in a new window.

By default, this flag is not present.

If the action's FileSpecification is not a PDF, this flag is ignored.

### to_string

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

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

A string describing this Action.

Returns a string representation of 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.
