How can I get the FileSpec from the GoToR Action in a Bookmark?

Q:

I can add bookmarks containing GoToR actions just fine and they work correctly. However, when I went to adapt your sample code that prints the outline hierarchy, I couldn’t find how to recover the FileSpec from the GoToR Action. What did I miss?

A:

Unfortunately the high-level “PDF” API does not provide a way to get the FileSpec object directly from a GoToR bookmark. You can, however, get it from the low-level “SDF” API. For example, to recover the filespec of “remoteBookmark1” in the sample, you could do:

if (remoteBookmark1.GetAction().GetType() == pdftron.PDF.Action.Type.e_GoToR)
{
Obj value = remoteBookmark1.GetSDFObj().FindObj(“A”).FindObj(“F”).Find(“F”).Value();
if (value != null) Console.WriteLine("File spec: " + value.GetAsPDFText());
}