PDF Bookmarks (properly called the document outline) represent a tree
of references to parts of the file, typically displayed at the side of the
screen. The user can click on one to move to the specified place.
Cpdflib
provides facilities to list, add, and remove bookmarks. The
format used by the list and add operations is the same, so you can feed the
output of one into the other, for instance to copy bookmarks.
Each bookmark has four elements:
For example:
If the page number is 0, it indicates that clicking on that entry doesn't move to a page.
To add bookmarks, build a suitable bookmark array using MakeBookmarks
and call AddBookmarks
.
It's important that the bookmarks passed to AddBookmarks
are consistent - that is, that the levels represent a proper tree form.
The function GetBookmarks
returns an array of all the bookmarks (if any) in a document.
The bookmark data structure can then be inspected:
The bookmarks in a document can be removed with RemoveBookmarks
.