Hi, Support:
Is there any way to extract the hyperlinks text or url from pdf pages based on VB.NET?
As well as ,disabled or remove the hyerlinks?
Thanks for your help!
Hi, Support:
Is there any way to extract the hyperlinks text or url from pdf pages based on VB.NET?
As well as ,disabled or remove the hyerlinks?
Thanks for your help!
It depends upon how hyperlinks are added in the PDF document. Are they added using annotations or JavaScript actions? Would you kindly share a sample PDF document with us so that we can test the scenario in our environment and address it accordingly.
Below is the code snippet to extract the hyperlinks from your PDF:
Dim pdfDocument As New Document(dataDir & "Demo.pdf")
Dim pages As PageCollection = pdfDocument.Pages
For Each p As Page In pages
For Each annot As Annotation In p.Annotations
If annot.AnnotationType = AnnotationType.Link Then
Dim a As LinkAnnotation = CType(annot, LinkAnnotation)
Dim URL As String = String.Empty
Dim dest As IAppointment = a.Destination
If a.Action IsNot Nothing OrElse dest IsNot Nothing Then
If a.Action IsNot Nothing Then
If TypeOf a.Action Is GoToURIAction Then
Console.WriteLine(DirectCast(a.Action, GoToURIAction).URI)
End If
End If
End If
End If
Next
Next
And in order to delete/remove the hyperlinks, you can simply remove the annotations from the PDF page:
Dim pdfDocument As New Document("input.pdf")
' Iterate through the pages
For Each page As Page In pdfDocument.Pages
' Remove hyperlinks from the page
page.Annotations.Clear()
Next
pdfDocument.Save("output.pdf")
Thanks!
And another issue is that how to get the screen tip text of the hyperlink?
By screen tip, do you mean the tooltip or title of the hyperlink that appears while hovering the link?
Yes!
what is the method to get the tooltip or title of the hyperlink that appears while hovering the link.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-55684
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.