COSBase parent = page;
while (((COSDictionary) parent).getDictionaryObject("Parent", "P") != null) {
parent = ((COSDictionary) parent).getDictionaryObject( "Parent", "P" );
}
// now parent is the pages node
PDPageNode pages = new PDPageNode((COSDictionary) parent);
List<PDPage> allPages = new ArrayList<PDPage>();
pages.getAllKids(allPages);
retval = allPages.indexOf(new PDPage((COSDictionary) page)) + 1;
}
}
return retval;
}