We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Read Bookmarks in PDF - Not able to determine whether its named action in Pdf Actions

Hi I have created a Named destinations and linked to Bookmarks, Hyperlinks.I am trying to read bookmarks for which I have linked the Named Destination. I am getting its class as GoTo insted I must get NamedAction. below is my code

(bkType.equals(GoToAction.class)) {
GoToAction actCol = ((GoToAction) childOutlineItem.getAction());
checkForGoToBookmark(childOutlineItem, objMap, actCol);
} else if (bkType.equals(GoToURIAction.class)) {
checkForWebUrlBookmark(childOutlineItem, objMap);
} else if (bkType.equals(LaunchAction.class)) {
LaunchAction action = (LaunchAction) childOutlineItem.getAction();
//to get absolute path for a open file
checkForLaunchBookmark(childOutlineItem, objMap, validateParams, action);
} else if (bkType.equals(GoToRemoteAction.class)) {
GoToRemoteAction action = (GoToRemoteAction) childOutlineItem.getAction();
checkForGoToRBookmark(childOutlineItem, validateParams, objMap, action);
} else if(bkType.equals(NamedAction.class)) {
NamedAction action = (NamedAction) childOutlineItem.getAction();
checkForNamedBookmark(childOutlineItem, validateParams, objMap, action);
}

@rampujar,

Thanks for contacting support.

Can you please share source file so that we may further investigation to help you out.

tenant_setup_tenant.pdf (34.5 KB)
tenant_setup_tenant_invalid.pdf (16.0 KB)

Hi Adnan.
FYA

Here I have created a Bookmarks, Hyperlinks for which I have linked Named destinations.
I need to verify that those Bookmarks/Hyperlinks that I have created have Valid Named Destinations. If named destination exists, the page number the named destination is referring to exists in a pdf or no.

  • tenant_setup_tenant.pdf conatins valid bookmarks/links with valid named destinations
  • tenant_setup_tenant_invalid.pdf contains invalid bookmarks/links with invalid named destinations.

Thanks
Sriram Pujar

@rampujar,

I have shared sample code with you. This will help you to identify named action exist or not in PDF.

string destinationName = "dest1";
Document doc = new Document("src.pdf");
if (doc.NamedDestinations[destinationName] !=null)
  Console.WriteLine("Destination exists");
else
  Console.WriteLine("Destination doe not exist");

Hi Adnan,
I have used the following code but I am getting this Exception

java.lang.NoClassDefFoundError: com/aspose/pdf/nameddestinations/NamedDestinationCollection

I am using 19.2 aspose.pdf version

@rampujar,

Can you please try to use Aspose.PDF latest version 19.12 on your end and share feedback with us if there is still an issue.