How to keep bookmark tree in sync with PDF pages?

Q:

In our app, at the time of file open, we are loading the bookmarks to
display them in a TreeView Control. We are also storing page number
for each TreeView Node. As we
have implemented Insert and Delete Pages functionality, presently
after Insert/Delete Operation, bookmark is not taking to the correct
page. To fix this problem, Do we
need to recurse through all the tree to adjust page numbers for each
TreeView Node or is there some other better way of doing it?
-----

A:

Instead of associating a tree node with a page number, you can
associate the node with a pdftron.PDF.Page object. This way even after
you insert new pages or delete existing pages you will be able to
obtain the correct page number (i.e. using page.GetIndex(); this
method returns -1 if the page is not part of document sequence - i.e.
it was deleted). This approach is illustrated in the latest version of
PDFView C# or VB.NET sample project (located in PDFNet/Samples folder;
http://www.pdftron.com/downloads/PDFNetDemo.zip).