Check existance of hyperlinks in PDf

Hi,


Is there a way to detect if a document contains hyperlink in a pdf document.

Regards,

Hi Rajeev,


Thanks for contacting support.

In order to accomplish your requirements, please try using following code snippet.

[Java]

//Open document<o:p></o:p>

com.aspose.pdf.Document document = new com.aspose.pdf.Document("c:/pdftest/update_Service_Work_Order.pdf");

//Extract actions

Page page = document.getPages().get_Item(1);

com.aspose.pdf.AnnotationSelector selector = new com.aspose.pdf.AnnotationSelector(new com.aspose.pdf.LinkAnnotation(page, com.aspose.pdf.Rectangle.getTrivial()));

page.accept(selector);

List list = selector.getSelected();

// Iterate through individual item inside list

if (list.size() == 0)

System.out.println("No Hyperlinks found..");

else

{

// Loop through all the bookmarks

for(com.aspose.pdf.LinkAnnotation annot : (Iterable)list)

{

// Print the destination URL

System.out.println("
Destination: "
+ ((com.aspose.pdf.GoToURIAction)annot.getAction()).getURI()+ "
"
);

}

}//
end else