# Bookmark Class

> A bookmark on a page of a PDF 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/Bookmark
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class Bookmark
```

**Namespace:** `datalogics_interface`

## Description

A bookmark on a page of a PDF document.

Each bookmark has a title that appears on screen, and an action that specifies what happens when a user clicks on the bookmark.

The typical action for a user-created bookmark is to move to another location in the current document, although any action (see Action) can be specified.

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

**Uses types:** [`Action`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Action.md), [`Bookmark`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md), [`BookmarkFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/BookmarkFlags.md), [`Color`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Color.md), [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md), [`ViewDestination`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ViewDestination.md)

## Constructors

### Bookmark

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

*constructor*

**Parameters**

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

### ~Bookmark

```cpp
datalogics_interface::Bookmark::~Bookmark()
```

*destructor*

## Methods

### add_child

```cpp
void datalogics_interface::Bookmark::add_child(Bookmark &child)
```

**Parameters**

- `child` ([`Bookmark &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md)): - the bookmark being added.

**Returns:** `void`

Add an existing bookmark to be the child bookmark of a parent.

### add_next_sibling

```cpp
void datalogics_interface::Bookmark::add_next_sibling(Bookmark &sibling)
```

**Parameters**

- `sibling` ([`Bookmark &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md)): - The bookmark to become the new right sibling.

**Returns:** `void`

Add a bookmark to a tree as the next (right) sibling.

### add_previous_sibling

```cpp
void datalogics_interface::Bookmark::add_previous_sibling(Bookmark &sibling)
```

**Parameters**

- `sibling` ([`Bookmark &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md)): - The bookmark to become the new left sibling.

**Returns:** `void`

Add a bookmark to a tree as the previous (left) sibling.

### add_subtree

```cpp
void datalogics_interface::Bookmark::add_subtree(Bookmark &subtree, const std::string &title)
```

**Parameters**

- `subtree` ([`Bookmark &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md)): - The bookmark subtree to add.
- `title` (`const std::string &`): - the title of the newly added subtree.

**Returns:** `void`

Add a copy of a subtree as the new last child of a parent bookmark, and gives the subtree an initial title.

### clear_action

```cpp
void datalogics_interface::Bookmark::clear_action()
```

**Returns:** `void`

Removes the action from this bookmark.

### create_new_child

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::create_new_child(const std::string &title)
```

**Parameters**

- `title` (`const std::string &`): - The initial title of the new child bookmark.

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

The newly created child bookmark.

(Deprecated, function may be removed in the future, use single-parameter CreateNewChild() method instead) Create a bookmark and add to a parent as the last child bookmark, and give the new bookmark an initial title.

### create_new_sibling

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::create_new_sibling(const std::string &title)
```

**Parameters**

- `title` (`const std::string &`): - The initial text for the new right sibling.

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

The newly created sibling bookmark.

Create a new bookmark in a tree as the next (right) sibling, using supplied string as the initial text.

### destroy

```cpp
void datalogics_interface::Bookmark::destroy()
```

**Returns:** `void`

Removes a bookmark subtree from the bookmark tree containing it.

### find_descendant_bookmark

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::find_descendant_bookmark(const std::string &title)
```

**Parameters**

- `title` (`const std::string &`): - The title of the bookmark for which to search.

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

The bookmark within this bookmark's tree that has the supplied title. Returns NULL if there is no bookmark with the supplied title.

Find bookmark by its title within the subtree of which this bookmark is the root, searching within the subtree to a depth determined by maxDepth (e.g., 0 = this bookmark only and not any of its children, 1 = search one level below this bookmark level, etc.)

### find_descendant_bookmark

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::find_descendant_bookmark(const std::string &title, int max_depth)
```

**Parameters**

- `title` (`const std::string &`): - The title of the bookmark for which to search.
- `max_depth` (`int`): - If supplied, declares the number of levels below this bookmark to search. (If omitted, the entire subtree is searched.)

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

The bookmark within this bookmark's tree that has the supplied title. Returns NULL if there is no bookmark with the supplied title.

Find bookmark by its title within the subtree of which this bookmark is the root, searching within the subtree to a depth determined by maxDepth (e.g., 0 = this bookmark only and not any of its children, 1 = search one level below this bookmark level, etc.)

### get_action

```cpp
std::unique_ptr< Action > datalogics_interface::Bookmark::get_action()
```

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

The action of the bookmark.

Get the Action for a bookmark.

### get_color

```cpp
std::unique_ptr< Color > datalogics_interface::Bookmark::get_color() const
```

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

the color, or null if no color was specified

Get the color of the bookmark.

### get_count

```cpp
int datalogics_interface::Bookmark::get_count() const
```

**Returns:** `int`

the number of open bookmarks.

Get the number of open bookmarks in the subtree under this bookmark.

### get_first_child

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::get_first_child() const
```

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

The first child of Bookmark, or null if Bookmark has no children.

Gets a bookmark's first child.

### get_flags

```cpp
BookmarkFlags datalogics_interface::Bookmark::get_flags() const
```

**Returns:** [`BookmarkFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/BookmarkFlags.md)

the flags

Get the flags for the bookmark.

### get_indent

```cpp
int datalogics_interface::Bookmark::get_indent() const
```

**Returns:** `int`

the indentation level of the bookmark.

Get the indentation level of a bookmark in its containing tree.

### get_last_child

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::get_last_child() const
```

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

The last child of Bookmark, or null if Bookmark has no children.

Gets a bookmark's last child.

### get_next

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::get_next() const
```

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

The Bookmark object's next (right) sibling. It returns null if Bookmark has no next sibling (that is, it is its parent's last child).

Gets a bookmark's next (right) sibling.

### get_parent

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::get_parent() const
```

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

The Bookmark object's parent. It returns null if Bookmark has no parent (that is, it is the root of the tree).

Gets a bookmark's parent.

### get_pdf_dict

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

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

The dictionary associated with the bookmark.

Get the dictionary associated with the bookmark.

### get_previous

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Bookmark::get_previous() const
```

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

The Bookmark object's previous (left) sibling. It returns null if Bookmark has no previous sibling (that is, it is its parent's first child).

Gets a bookmark's previous (left) sibling.

### get_title

```cpp
std::string datalogics_interface::Bookmark::get_title() const
```

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

The title of the bookmark.

### get_view_destination

```cpp
std::unique_ptr< ViewDestination > datalogics_interface::Bookmark::get_view_destination() const
```

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

the view destination

If this bookmark has a GoTo action, then return the destination of the action, else return null.

### has_children

```cpp
bool datalogics_interface::Bookmark::has_children() const
```

**Returns:** `bool`

true if the bookmark has children.

Does the bookmark have children?

### is_open

```cpp
bool datalogics_interface::Bookmark::is_open() const
```

**Returns:** `bool`

true if the bookmark is open.

Is the bookmark open?

### operator=

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

**Parameters**

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

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

### operator==

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

**Parameters**

- `other` ([`const Bookmark &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md)): The other Bookmark to compare against.

**Returns:** `bool`

true if the bookmarks are equal, false otherwise.

Compare two bookmarks for equality.

### set_action

```cpp
void datalogics_interface::Bookmark::set_action(const Action &action)
```

**Parameters**

- `action` ([`const Action &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Action.md)): - The action to set for the bookmark.

**Returns:** `void`

Set the Action for a bookmark.

### set_color

```cpp
void datalogics_interface::Bookmark::set_color(const Color &color)
```

**Parameters**

- `color` ([`const Color &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Color.md)): the color of the bookmark

**Returns:** `void`

Set the color of the bookmark.

### set_flags

```cpp
void datalogics_interface::Bookmark::set_flags(BookmarkFlags flags)
```

**Parameters**

- `flags` ([`BookmarkFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/BookmarkFlags.md))

**Returns:** `void`

Set the flags for the bookmark to the parameter values.

### set_open

```cpp
void datalogics_interface::Bookmark::set_open(bool open)
```

**Parameters**

- `open` (`bool`): if the bookmark is open or closed

**Returns:** `void`

Set if the bookmark is open or closed.

### set_title

```cpp
void datalogics_interface::Bookmark::set_title(const std::string &title)
```

**Parameters**

- `title` (`const std::string &`): the title of the bookmark

**Returns:** `void`

The title of the bookmark.

### to_string

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

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

A string describing this Bookmark and its properties.

Returns a string representation of this Bookmark.

The string includes the title, color, flags, count, indent level, open state, and view destination if available.

### unlink

```cpp
void datalogics_interface::Bookmark::unlink()
```

**Returns:** `void`

Unlinks the bookmark from the bookmark tree that contains it and adjusts the tree appropriately.
