DynaPDF.InsertBookmarkEx
------------------------

Inserts a bookmark in an existing outline tree.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [4.0](newinversion40.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.InsertBookmarkEx"; PDF; Title; Parent; NamedDest { ; Open; AddChildren } ) 

**MBS**( **"DynaPDF.InsertBookmarkEx";** /\* Inserts a bookmark in an existing outline tree. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Title**; /\* The Bookmark title.e.g. "Chapter 1" \*/   
**$Parent**; /\* Immediate parent bookmark. Must be a valid bookmark handle or -1.e.g. -1 \*/   
**$NamedDest**; /\* Named Destination handlee.g. $Dest \*/   
**$Open**; /\* Optional; Optional, whether to open or close the node when it contains children. Default is 0 to close.e.g. 1 \*/   
**$AddChildren**) /\* Optional; Optionally, add all bookmarks below the new one as children. Default 0.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| Title | The Bookmark title. | "Chapter 1" |  |
| Parent | Immediate parent bookmark. Must be a valid bookmark handle or -1. | -1 |  |
| NamedDest | Named Destination handle | $Dest |  |
| Open | Optional, whether to open or close the node when it contains children. Default is 0 to close. | 1 | Optional |
| AddChildren | Optionally, add all bookmarks below the new one as children. Default 0. | 0 | Optional |

### Result

Returns new bookmark handle or error.

### Description

Inserts a bookmark in an existing outline tree.   
It sets also the page mode to UseOutlines (see [DynaPDF.SetPageMode](DynaPDFSetPageMode.md)). If the outline tree should not be shown when opening the document then set the page mode back to UseNone or another value before closing the document.  
Parent can be the handle of the parent bookmark after the new bookmark should be inserted or -1. If Parent is set to -1 the bookmark is inserted as the first root node in the outline tree.  
If the parameter AddChildren is set to 1, the bookmarks below the new one are added as children to the new bookmark. This can be useful when merging PDF files and if the bookmarks from each PDF file should be separated.  
NamedDest must be a valid handle from a named destination, see [DynaPDF.CreateNamedDest](DynaPDFCreateNamedDest.md) for further information. If the destination lies in another document then insert the bookmark with [DynaPDF.InsertBookmark](DynaPDFInsertBookmark.md), create an extended Go To Remote Action with [DynaPDF.CreateGoToRActionEx](DynaPDFCreateGoToRActionEx.md), and add the action finally to the bookmark with [DynaPDF.AddActionToObj](DynaPDFAddActionToObj.md).  
Notice: When inserting a bookmark the handles of all bookmarks below the new one are incremented by one.  
See also [InsertBookmarkEx](https://www.monkeybreadsoftware.com/DynaPDF-Manual/InsertBookmarkEx.shtml) function in DynaPDF manual.

### See also

- [DynaPDF.AddActionToObj](DynaPDFAddActionToObj.md)
- [DynaPDF.AddBookmark](DynaPDFAddBookmark.md)
- [DynaPDF.AddBookmarkEx](DynaPDFAddBookmarkEx.md)
- [DynaPDF.CreateGoToRAction](DynaPDFCreateGoToRAction.md)
- [DynaPDF.CreateGoToRActionEx](DynaPDFCreateGoToRActionEx.md)
- [DynaPDF.CreateNamedDest](DynaPDFCreateNamedDest.md)
- [DynaPDF.FindNextBookmark](DynaPDFFindNextBookmark.md)
- [DynaPDF.InsertBookmark](DynaPDFInsertBookmark.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetPageMode](DynaPDFSetPageMode.md)

This function checks for a license.

Created 18th August 2014 , last changed 18th August 2014

  
[DynaPDF.InsertBookmark](DynaPDFInsertBookmark.md) - [DynaPDF.InsertImage](DynaPDFInsertImage.md)

[HTML Version](DynaPDFInsertBookmarkEx.shtml)