Search code examples
c#pdfbookmarks

PDFNet - how do I get all bookmarks


I'm using the PDFnet SDK for c#. I want to list in my own window all bookmarks.

However, I find the only way to get to the first bookmark, but not the other bookmarks.

this is my code:

namespace David.PDFTest
{
    public partial class PDFView : PDFViewCtrl
    {
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Trace.WriteLine(GetDoc().GetFirstBookmark().GetTitle());
        }
    }
}

is there the possibility to get all the bookmarks?


Solution

  • It seems that there is a Bookmark.GetNext() method which you could use.

    So I would write something like this:

    namespace David.PDFTest
    {
        public partial class PDFView : PDFViewCtrl
        {
            protected override void OnMouseDown(MouseEventArgs e)
            {   
                var bm = GetDoc().GetFirstBookmark();
                while ( bm!=null )
                {
                    Trace.WriteLine(bm.GetTitle());
                    bm = bm.GetNext();
                }
            }
        }
    }