Rank: Newbie
Groups: Registered
Joined: 6/16/2022(UTC) Posts: 2 
|
Hi! I´m trying to get a value of a link clicked in pdf. In "PdfBeforeLinkClickedEventArgs" the "e" is not giving me enough information! I´ve tried that so far: Code:Private Sub PdfViewer1_BeforeLinkClicked(sender As Object, e As Patagames.Pdf.Net.EventArguments.PdfBeforeLinkClickedEventArgs) Handles PdfViewer1.BeforeLinkClicked
e.Cancel = True
Dim weblink = e.WebLink
Dim link = e.Link
Dim pageIndex = PdfViewer1.CurrentPage.PageIndex
Dim page As PdfPage = PdfViewer1.Document.Pages(pageIndex)
If Not IsNothing(weblink) Then
Debug.WriteLine("Weblink")
End If
If Not IsNothing(link) Then
Dim _handle = link.Handle
For Each _pair In link.Dictionary
'I need text written on control and destination URI
Next
End If
End Sub
Edited by user Saturday, June 18, 2022 10:18:34 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,075
Thanks: 6 times Was thanked: 124 time(s) in 121 post(s)
|
Hello, for web links PdfWebLink.UrlInfo property to get URL for other links the Destination/Action property. Here are еру details about actions https://pdfium.patagames...l/WorkingSDK_Actions.htmand Destinations https://pdfium.patagames...kingSDK_Destinations.htmThe destination cannot be a URI, so the action is of interest to you. Code:public virtual void ProcessAction(PdfAction pdfAction)
{
switch (pdfAction.ActionType)
{
case ActionTypes.Uri:
var ps = new ProcessStartInfo((pdfAction as PdfUriAction).ActionUrl) { UseShellExecute = true, Verb = "open" };
Process.Start(ps);
break;
}
}
Links (web links, actions, and destinations) do not contain text on their own. They are placed above the text object (or any other object). so you need to get the bounds of the link and get the text using the GetBoundedText method. page.Text.GetBoundedText()
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 6/16/2022(UTC) Posts: 2 
|
OK, thank you! I get Text from Link like this: Code: Private Sub PdfView_BeforeLinkClicked(sender As Object, e As EventArguments.PdfBeforeLinkClickedEventArgs) Handles PdfView.BeforeLinkClicked
Dim weblink = e.WebLink
Dim link = e.Link
Dim pageIndex = PdfView.CurrentPage.PageIndex
Dim page As PdfPage = PdfView.Document.Pages(pageIndex)
'Dim document = PdfView.Document.Handle
If Not IsNothing(link) Then
'Dim _handle = link.Handle
Dim pdfLink = page.Text.GetBoundedText(link.AnnotationRect)
If Not String.IsNullOrWhiteSpace(pdfLink) OrElse Not String.IsNullOrEmpty(pdfLink) Then
If IsNothing(link.Destination) Then
Debug.WriteLine("DestinationType - Nothing")
Debug.WriteLine(pdfLink)
e.Cancel = True
CefSharp.WebBrowserExtensions.LoadHtml(frmWebBrowser.ChromiumWebBrowser,
frmWebBrowser.CreatePage(pdfLink))
tabBrowser.ShowOnlyMe()
End If
End If
End If
End Sub
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close