Sorry i am new to PDF box and was looking for a solution on how to get a specific pdf page using the bookmark name? Like the below code snippet am trying to loop all the pages b
It turns out that in your PDF the page destination is not in the bookmark's destination entry, but in the bookmark's action entry (yes, PDF makes it possible to have two ways to do the same thing). Add this to your code:
if (current.getDestination() instanceof PDPageDestination)
{
PDPageDestination pd = (PDPageDestination) current.getDestination();
System.out.println("Destination page: " + (pd.retrievePageNumber() + 1));
return pd.getPage();
}
if (current.getAction() instanceof PDActionGoTo)
{
PDActionGoTo gta = (PDActionGoTo) current.getAction();
if (gta.getDestination() instanceof PDPageDestination)
{
PDPageDestination pd = (PDPageDestination) gta.getDestination();
System.out.println("Destination page: " + (pd.retrievePageNumber() + 1));
return pd.getPage();
}
}