Public Types | |
enum | Position { e_PosFirstChild = 0, e_PosLastChild = 1, e_PosPrevSibling = 2, e_PosNextSibling = 3, e_PosFirstSibling = 4, e_PosLastSibling = 5 } |
Enumeration for bookmark position. More... | |
enum | Style { e_StyleNormal = 0x00, e_StyleItalic = 0x01, e_StyleBold = 0x02 } |
Enumeration for bookmark style type. More... | |
Public Member Functions | |
Bookmark (const PDFDoc &pdf_doc, objects::PDFDictionary *bookmark_dict) | |
Constructor, with parameters. More... | |
Bookmark (const Bookmark &other) | |
Constructor, with another bookmark object. More... | |
~Bookmark () | |
Destructor. | |
actions::Action | GetAction () |
Get action. More... | |
RGB | GetColor () const |
Get the color used for displaying title. More... | |
Destination | GetDestination () |
Get the destination. More... | |
objects::PDFDictionary * | GetDict () const |
Get PDF dictionary of current bookmark. More... | |
Bookmark | GetFirstChild () |
Get the first child bookmark. More... | |
Bookmark | GetNextSibling () |
Get the next sibling bookmark. More... | |
Bookmark | GetParent () |
Get the parent bookmark. More... | |
uint32 | GetStyle () const |
Get the style. More... | |
WString | GetTitle () const |
Get the title. More... | |
bool | HasChild () |
Check if current bookmark has child bookmark(s). More... | |
Bookmark | Insert (const WString &title, Position position) |
Insert a new bookmark according to the relationship position to current bookmark. More... | |
bool | IsEmpty () const |
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 (const Bookmark &dest_bookmark, Position position) |
Move current bookmark to be child or sibling of another bookmark. More... | |
bool | operator!= (const Bookmark &other) const |
Not equal operator. More... | |
Bookmark & | operator= (const Bookmark &other) |
Assign operator. More... | |
bool | operator== (const Bookmark &other) const |
Equal operator. More... | |
bool | RemoveAction () |
Remove action. More... | |
void | SetAction (const actions::Action &action) |
Set action. More... | |
void | SetColor (RGB color) |
Set the color used for displaying title. More... | |
void | SetDestination (const Destination &destination) |
Set the destination. More... | |
void | SetStyle (uint32 style) |
Set the style. More... | |
void | SetTitle (const WString &title) |
Set the title. More... | |
![]() | |
FS_HANDLE | Handle () const |
Get the handle of current object. More... | |
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 PDFDoc::GetRootBookmark must be called first to get the root of the whole bookmark tree. If the "root bookmark" does not exist, function PDFDoc::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 Bookmark::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:
This class also offers functions to get/set the data of a PDF bookmark.
Enumeration for bookmark position.
Values of this enumeration should be used alone.
Actually, "bookmark position" means the relationship between a bookmark and another bookmark.
foxit::pdf::Bookmark::Bookmark | ( | const PDFDoc & | pdf_doc, |
objects::PDFDictionary * | bookmark_dict | ||
) |
Constructor, with 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. |
foxit::pdf::Bookmark::Bookmark | ( | const Bookmark & | other | ) |
Constructor, with another bookmark object.
[in] | other | Another bookmark object. |
actions::Action foxit::pdf::Bookmark::GetAction | ( | ) |
Get action.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::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 actions::Action::IsEmpty returns true.
RGB foxit::pdf::Bookmark::GetColor | ( | ) | const |
Get the color used for displaying title.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::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 foxit::pdf::Bookmark::GetDestination | ( | ) |
Get 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 Destination::IsEmpty returns true.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::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 Destination::IsEmpty returns true.
objects::PDFDictionary* foxit::pdf::Bookmark::GetDict | ( | ) | const |
Get PDF dictionary of current bookmark.
Bookmark foxit::pdf::Bookmark::GetFirstChild | ( | ) |
Get the first child bookmark.
Bookmark foxit::pdf::Bookmark::GetNextSibling | ( | ) |
Get the next sibling bookmark.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::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 Bookmark::IsEmpty returns true.
Bookmark foxit::pdf::Bookmark::GetParent | ( | ) |
Get the parent bookmark.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::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 Bookmark::IsEmpty returns true.
uint32 foxit::pdf::Bookmark::GetStyle | ( | ) | const |
Get the style.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have style information. In this case, this function will return Bookmark::e_StyleNormal by default.
WString foxit::pdf::Bookmark::GetTitle | ( | ) | const |
Get the title.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have title. In this case, this function will return an empty string.
bool foxit::pdf::Bookmark::HasChild | ( | ) |
Check if current bookmark has child bookmark(s).
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 Bookmark::e_StyleNormal by default.
[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 Bookmark::e_PosFirstChild and this should be one of these values. If current bookmark is just the "root bookmark", parameter position can only be Bookmark::e_PosFirstChild or Bookmark::e_PosLastChild. |
bool foxit::pdf::Bookmark::IsEmpty | ( | ) | const |
Check whether current object is empty or not.
When the current object is empty, that means current object is useless.
bool foxit::pdf::Bookmark::IsFirstChild | ( | ) |
Check if current bookmark is the first child of its parent bookmark.
bool foxit::pdf::Bookmark::IsLastChild | ( | ) |
Check if current bookmark is the last child of its parent bookmark.
bool foxit::pdf::Bookmark::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.
Move current bookmark to be child or sibling of another bookmark.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::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 false directly.
[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 Bookmark::e_PosFirstChild and this should be one of these values. |
bool foxit::pdf::Bookmark::operator!= | ( | const Bookmark & | other | ) | const |
Not equal operator.
[in] | other | Another bookmark object. This function will check if current object is not equal to this one. |
Assign operator.
[in] | other | Another bookmark object, whose value would be assigned to current object. |
bool foxit::pdf::Bookmark::operator== | ( | const Bookmark & | other | ) | const |
Equal operator.
[in] | other | Another bookmark object. This function will check if current object is equal to this one. |
bool foxit::pdf::Bookmark::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 PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have any action information. In this case, this function will return true directly.
void foxit::pdf::Bookmark::SetAction | ( | const actions::Action & | action | ) |
Set action.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have any action information. In this case, this function will return directly without doing anything.
[in] | action | A valid action to be set. Currently only support following types as the new action: actions::Action::e_TypeGoto, actions::Action::e_TypeURI, actions::Action::e_TypeJavaScript, actions::Action::e_TypeNamed, actions::Action::e_TypeGoToR, actions::Action::e_TypeGoToE, actions::Action::e_TypeSubmitForm, actions::Action::e_TypeResetForm, actions::Action::e_TypeHide, actions::Action::e_TypeLaunch, actions::Action::e_TypeImportData, actions::Action::e_TypeRendition. |
void foxit::pdf::Bookmark::SetColor | ( | RGB | color | ) |
Set the color used for displaying title.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have color. In this case, this function will return directly without doing anything.
[in] | color | New color used for displaying title. Format:0xRRGGBB. |
void foxit::pdf::Bookmark::SetDestination | ( | const Destination & | destination | ) |
Set the destination.
Bookmark's destination is some place in current document where the bookmark can "goto".
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have any destination information. In this case, this function will return directly without doing anything.
[in] | destination | A valid destination. |
void foxit::pdf::Bookmark::SetStyle | ( | uint32 | style | ) |
Set the style.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have style information. In this case, this function will return directly without doing anything.
[in] | style | New bookmark style. Please refer to values starting from Bookmark::e_StyleNormal and this can be one or a combination of these values. If the style is invalid, Bookmark::e_StyleNormal will be set by default. |
void foxit::pdf::Bookmark::SetTitle | ( | const WString & | title | ) |
Set the title.
If current bookmark is returned by function PDFDoc::GetRootBookmark or PDFDoc::CreateRootBookmark, that means it is the "root bookmark", and it does not have title. In this case, this function will return directly without doing anything.
[in] | title | New title string. It should not be an empty string. |