I need to parse URLs if an anchor link exists in a PDF file. I created a very small Word document with a hyperlink and saved it as PDF. I then tried to display the URL using the technique mentioned on https://github.com/aspose-pdf/Aspose.PDF-for-Java/blob/master/Examples/src/main/java/com/aspose/pdf/examples/AsposePdfExamples/LinksAndActions/GetPDFHyperlinkDestination.java . However, it does not list any entries.
Any suggestions. I can certainly upload the PDF file is you like.
@petarian
Yes, please share the sample PDF document so that we can test the scenario in our environment and address it accordingly. Please also share how you are converting the Word document into PDF?
See attached file. invoice2.pdf (35.8 KB)
@petarian
We were able to notice the issue in our environment while using Aspose.PDF for Java 20.12. Therefore, we have logged an issue as PDFJAVA-40055 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification.
Furthermore, we have also tried following code snippet and were able to extract the link destination successfully. Would you please try below code and let us know if it fulfills your needs:
Document document = new Document(dataDir + "invoice2.pdf");
// Extract actions
Page page = document.getPages().get_Item(1);
for(com.aspose.pdf.Annotation annot : page.getAnnotations())
{
LinkAnnotation link = (LinkAnnotation)annot;
System.out.println("<br />Destination: " + ((GoToURIAction) link.getAction()).getURI() + "<br />");
}
Perfect. This works on my end as well.
1 Like
@petarian
It is good to know that your issue has been resolved. Please keep using our API and we will surely inform you as soon as we have some news regarding resolution of the logged ticket.
@petarian
We have uncommented the code page.accept(selector);
in the code snippet and it will work now. It is the function that makes the search. The ticket has been investigated and closed now.