logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Morrison Posted: Sunday, June 26, 2022 2:06:45 PM(UTC)
 
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
Paul Rayman Posted: Saturday, June 18, 2022 7:52:42 PM(UTC)
 
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.com/help/html/WorkingSDK_Actions.htm

and Destinations
https://pdfium.patagames.com/help/html/WorkingSDK_Destinations.htm

The 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()
Morrison Posted: Thursday, June 16, 2022 9:32:54 AM(UTC)
 
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