{
throw new OutlineNotLocalException( "Error: Outline does not reference a local page." );
}
}
PDPageDestination pageDest = null;
if( rawDest instanceof PDNamedDestination )
{
//if we have a named destination we need to lookup the PDPageDestination
PDNamedDestination namedDest = (PDNamedDestination)rawDest;
PDDocumentNameDictionary namesDict = doc.getDocumentCatalog().getNames();
if( namesDict != null )
{
PDDestinationNameTreeNode destsTree = namesDict.getDests();
if( destsTree != null )
{
pageDest = (PDPageDestination)destsTree.getValue( namedDest.getNamedDestination() );
}
}
}
else if( rawDest instanceof PDPageDestination)
{
pageDest = (PDPageDestination) rawDest;
}
else if( rawDest == null )
{
//if the destination is null then we will simply return a null page.
}
else
{
throw new IOException( "Error: Unknown destination type " + rawDest );
}
if( pageDest != null )
{
page = pageDest.getPage();
if( page == null )
{
int pageNumber = pageDest.getPageNumber();
if( pageNumber != -1 )
{
List allPages = doc.getDocumentCatalog().getAllPages();
page = (PDPage)allPages.get( pageNumber );
}