How to obtain all destination proporties (e.g. so I can recreate the destination)?


I would like to programmatically using PDFNET, open a pdf file and
traverse through all the bookmarks and try to create named
destinations. The problem I run into is I don't know how to retrieve
the underlying SDF/COS bookmark location/coordinate etc information in
order to create the named destination. How do I use SDF/COS to
retrieve the underlying bookmark information?


Given an existing 'Destination' object you can access all entries in
the destination dictionary as follows:

Action action = bookmark.GetAction();
if (action.IsValid() && action.GetType() == Action.Type.e_GoTo) {

  Destination dest = action.GetDest();
  // Extract other info from the low level destination...
  Obj dest_arr = itr.Value();
  string fit_type = dest_arr.GetAt(1).GetName();
  if (fit_type == "FitH") {
     // dest_arr.Size() should return 3.
     // Now get the vertical coordinate 'top'
     double top = dest_arr.GetAt(2).GetNumber();
  else {
    // See section 8.2.1 'Destinations' in PDF Reference
    // for other destination 'fit' types.

The following FAQ may be relevant if you want to obtain a destination
from a remote document:

  Simply serch for: "How do I obtain remote file destinations from a
link annotation or from a bookmark item?" in this forum.

Things are much simpler if all bookmark destinations are internal to
the document.
In that case you can obtain the bookmark action, then destination, and
finally destination page number and positioning (from dest_arr).


Hi, thanks for your help. I am able to access destination information
from using the lower level SDP object. Not sure why the higher level
Destination object's location information is empty.

I am glad to hear stuff is working on your end. We will add more high-
level 'wrappers' over time, but as you can see using current PDFNet
SDF API it is also very easy to access any required PDF (or custom)