Foxit PDF SDK

Instance Methods | Properties | List of all members
FSBookmark Class Reference
Inheritance diagram for FSBookmark:

## Instance Methods
(FSPDFDictionary *) | - getDict
| Get PDF dictionary of current bookmark. More...
(FSBookmark *) | - getFirstChild
| Get the first child bookmark. More...
(FSBookmark *) | - getNextSibling
| Get the next sibling bookmark. More...
(FSBookmark *) | - getParent
| Get the parent bookmark. More...
(BOOL) | - hasChild
| Check if current bookmark has child bookmark(s). More...
(id) | - initWithOther:
| Constructor, with another bookmark object. More...
(id) | - initWithPdf_doc:bookmark_dict:
| Constructor, with parameters. More...
(FSBookmark *) | - insert:position:
| Insert a new bookmark according to the relationship position to current bookmark. More...
(BOOL) | - isEmpty
| Check whether current object is empty or not. More...
(BOOL) | - isFirstChild
| Check if current bookmark is the first child of its parent bookmark. More...
(BOOL) | - isLastChild
| Check if current bookmark is the last child of its parent bookmark. More...
(BOOL) | - isRoot
| Check if current bookmark is the root bookmark. More...
(BOOL) | - moveTo:position:
| Move current bookmark to be child or sibling of another bookmark. More...
(BOOL) | - removeAction
| Remove action. More...

## Properties
FSAction * | action
| Get or Set action. More...
unsigned int | color
| Get or Set the color used for displaying title. More...
FSDestination * | destination
| Get or Set the destination. More...
unsigned int | style
| Get or Set the style. More...
NSString * | title
| Get or Set the title. More...

## Detailed Description

PDF bookmark is also called "outline". It's a tree-structured hierarchy. It allows user to navigate PDF document easily by selecting a bookmark. One bookmark contains a destination or actions to indicate how to response when user selects it.
In order to get/set the bookmark tree, function FSPDFDoc::getRootBookmark must be called first to get the root of the whole bookmark tree. If the "root bookmark" does not exist, function FSPDFDoc::createRootBookmark could be called to create a new "root bookmark". Here, "root bookmark" is an abstract object. It represents the "Outline" of PDF document. For more details about "Outline", please refer to Section 8.2.3 in PDF Reference 1.7. "root bookmark" can only have some child bookmarks, but no parent, no next sibling bookmarks or any data (including bookmark data, destination data and action data). And "root bookmark" cannot be shown on the application UI since it has no data. So, for a root bookmark, only function FSBookmark::getFirstChild can be used.
From the root bookmark, the bookmark tree can be traversed and each bookmark node can be accessed.
This class offers several functions to get/set other bookmarks from current bookmark. For example:

- To access the parent bookmark, use function FSBookmark::getParent.
- To access the first child bookmark, use function FSBookmark::getFirstChild.
- To access the next sibling bookmark, use function FSBookmark::getNextSibling.
- To Insert a new bookmark, use function FSBookmark::insert:position:.
- To move a bookmark, use function FSBookmark::moveTo:position:.

This class also offers functions to get/set the data of a PDF bookmark.

See also
  FSPDFDoc

## Method Documentation

## ◆ getDict()

- (FSPDFDictionary *) getDict |  |  |

Get PDF dictionary of current bookmark.

Returns
  The PDF dictionary. If there is any error, this function will return nil.

## ◆ getFirstChild()

- (FSBookmark *) getFirstChild |  |  |

Get the first child bookmark.

Returns
  The first child bookmark object.

## ◆ getNextSibling()

- (FSBookmark *) getNextSibling |  |  |

Get the next sibling bookmark.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have any sibling bookmark. In this case, this function will return a bookmark object which's function FSBookmark::isEmpty returns YES.

Returns
  The next sibling bookmark object.

## ◆ getParent()

- (FSBookmark *) getParent |  |  |

Get the parent bookmark.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have a parent bookmark. In this case, this function will return a bookmark object which's function FSBookmark::isEmpty returns YES.

Returns
  The parent bookmark object.

## ◆ hasChild()

- (BOOL) hasChild |  |  |

Check if current bookmark has child bookmark(s).

Returns
  YES means current bookmark has child bookmark(s), and NO means current bookmark does not have any child bookmark.

## ◆ initWithOther:()

- (id) initWithOther: |  | (FSBookmark*) | other |

Constructor, with another bookmark object.

Parameters

  [in] | other | Another bookmark object.

## ◆ initWithPdf_doc:bookmark_dict:()

- (id) initWithPdf_doc: |  | (FSPDFDoc*) | pdf_doc
bookmark_dict: |  | (FSPDFDictionary*) | bookmark_dict

Constructor, with parameters.

Parameters

  [in] | pdf_doc | A valid PDF document object.
  [in] | bookmark_dict | A PDF dictionary which represents a bookmark. This PDF dictionary should have existed in the PDF document represented by parameter pdf_doc.

## ◆ insert:position:()

- (FSBookmark *) insert: |  | (NSString *) | title
position: |  | (FSBookmarkPosition) | position

Insert a new bookmark according to the relationship position to current bookmark.

For the new bookmark, the color would be 0x000000 and the style would be FSBookmarkStyleNormal by default.

Parameters

  [in] | title | Title string for the new bookmark. It should not be an empty string.
  [in] | position | The position where the new bookmark item is to be inserted, based on current bookmark. Please refer to values starting from FSBookmarkPosFirstChild and this should be one of these values. If current bookmark is just the "root bookmark", parameter position can only be FSBookmarkPosFirstChild or FSBookmarkPosLastChild.

Returns
  A new bookmark object.

## ◆ isEmpty()

- (BOOL) isEmpty |  |  |

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
  YES means current object is empty, while NO means not.

## ◆ isFirstChild()

- (BOOL) isFirstChild |  |  |

Check if current bookmark is the first child of its parent bookmark.

Returns
  YES means current bookmark is the first child of its parent bookmark, while NO means not.

## ◆ isLastChild()

- (BOOL) isLastChild |  |  |

Check if current bookmark is the last child of its parent bookmark.

Returns
  YES means current bookmark is the last child of its parent bookmark, while NO means not.

## ◆ isRoot()

- (BOOL) isRoot |  |  |

Check if current bookmark is the root bookmark.

"root bookmark" is an abstract object. It represents the "Outline" of PDF document. For more details about "Outline", please refer to Section 8.2.3 in PDF Reference 1.7. "root bookmark" can only have some child bookmarks, but no parent, no next sibling bookmarks or any data (including bookmark data, destination data and action data). And "root bookmark" cannot be shown on the application UI since it has no data.

Returns
  YES means current bookmark is the root bookmark, while NO means not.

## ◆ moveTo:position:()

- (BOOL) moveTo: |  | (FSBookmark*) | dest_bookmark
position: |  | (FSBookmarkPosition) | position

Move current bookmark to be child or sibling of another bookmark.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it cannot be moved to be child or sibling of any bookmark in the bookmark tree. In this case, this function will return NO directly.

Parameters

  [in] | dest_bookmark | The destination bookmark. It should not be current bookmark itself or any descendant of current bookmark. Current bookmark will be moved to be child or sibling of the destination bookmark.
  [in] | position | The position where the current bookmark is to be moved to, based on parameter destBookmark. Please refer to values starting from FSBookmarkPosFirstChild and this should be one of these values.

Returns
  YES means success, while NO means failure.

## ◆ removeAction()

- (BOOL) removeAction |  |  |

Remove action.

When removing bookmark's action, bookmark's destination will be removed at the same time.
If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have any action information. In this case, this function will return YES directly.

Returns
  YES means success, while NO means failure.

## Property Documentation

## ◆ action

- (FSAction *) action
| read write nonatomic weak

Get or Set action.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have any action information. In this case, this function will return an action object which's function FSAction::isEmpty returns YES.

## ◆ color

- (unsigned int) color
| read write nonatomic assign

Get or Set the color used for displaying title.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have color. In this case, this function will return 0x000000 by default.

## ◆ destination

- (FSDestination *) destination
| read write nonatomic weak

Get or Set the destination.

Bookmark's destination is some place in current document where the bookmark can "goto". If the bookmark cannot "goto" any place in current document, that means no destination information can be retrieved and this function will return a destination object which's function FSDestination::isEmpty returns YES.
If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have any destination information. In this case, this function will return a destination object which's function FSDestination::isEmpty returns YES.

## ◆ style

- (unsigned int) style
| read write nonatomic assign

Get or Set the style.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have style information. In this case, this function will return FSBookmarkStyleNormal by default.

## ◆ title

- (NSString *) title
| read write nonatomic weak

Get or Set the title.

If current bookmark is returned by function FSPDFDoc::getRootBookmark or FSPDFDoc::createRootBookmark, that means it is the "root bookmark", and it does not have title. In this case, this function will return an empty string.