Q:
I need to know how to get a Destination given a PDF and a Destination
Name. Then once I have the destination I can use the
dest.GetPage().GetPageIndex() code, but I am still at the point of
getting the destination. I tried using bookmarks to get the
destination
Bookmark item = m_pdfdoc.GetFirstBookmark().Find(i.Key().GetStr());
if (item.IsValid())
This code gave me bookmarks but not destinations. Is there a way to
get the destination on a PDF that do not have an associated bookmark?
How can I access/find named destinations in PDF?
----
A:
You can access named destinations directly as follows:
Using C++:
init pdfnet
...
PDFDoc doc("mypdf.pdf");
doc.InitSecurityHandler();
NameTree dests = NameTree::Find(doc, "Dests");
if (!dests.IsValid()) return;
// Traversing all destinations in Dests NameTree
NameTreeIterator end = dests.End();
NameTreeIterator i = dests.Begin();
for (; i!=end; ++i) {
cout << "Key: " << i->Key()->GetStr() << endl;
}
// Searching the NameTree
i = dests.Find("MyDest", 6);
cout << "Key: " << i->Key()->GetStr() << endl;
cout << "Value: " << i->Value()->GetType() << endl;
...
Using C#:
init pdfnet
...
PDFDoc doc = new PDFDoc("mypdf.pdf");
doc.InitSecurityHandler();
NameTree dests = SDF.NameTree.Find(doc, "Dests");
if (!dests.IsValid()) return;
// Traversing all destinations in Dests NameTree
SDF.NameTreeIterator end = dests.End();
SDF.NameTreeIterator i = dests.Begin();
for (; i!=end; ++i) {
// i.Key().GetStr()
}
// Searching the NameTree
i = dests.Find("MyDest", 6);
// Key: i.Key().GetStr()
// Value: i.Value()
...