{System.out.println("No names dictionary.");}
else
{
System.out.println("Names dictionary found (" + names.getContainer().getReference() + ")");
NamedDestinations namedDestinations = names.getDestinations();
if(namedDestinations == null)
{System.out.println("No named destinations.");}
else
{
System.out.println("Named destinations found (" + namedDestinations.getContainer().getReference() + ")");
// Parsing the named destinations...
for(Map.Entry<PdfString,Destination> namedDestination : namedDestinations.entrySet())
{
PdfString key = namedDestination.getKey();
Destination value = namedDestination.getValue();
System.out.println("Destination '" + key.getValue() + "' (" + value.getContainer().getReference() + ")");
System.out.print(" Target Page: number = ");
Object pageRef = value.getPageRef();
if(pageRef instanceof Integer) // NOTE: numeric page refs are typical of remote destinations.
{System.out.println(((Integer)pageRef) + 1);}
else // NOTE: explicit page refs are typical of local destinations.
{
Page page = (Page)pageRef;
System.out.println((page.getIndex() + 1) + "; ID = " + ((PdfReference)page.getBaseObject()).getId());
}
}
System.out.println("Named destinations count = " + namedDestinations.size());
}
}
return true;
}