Flexviewer - Get clicked Link

Posted by: andreas.fischer on 9 September 2018, 9:10 pm EST

  • Posted 9 September 2018, 9:10 pm EST

    Hi there again,

    is there any way to get the URI of the current clicked link inside a pdf? This is crucial to act on specific links to override default and implement custom action (thus like capturing specific links and don't open them, but take a custom action)?

    Other frameworks let handle you link handlers, but it seems c1 flexviewer is "eating" up the events, not bubbling up and not having any attachable "hyperlinklistener"??

    Best regards,
    Andreas
  • Marked as Answer

    Replied 10 September 2018, 7:48 pm EST

    Hello Andreas,

    For this you may use the HyperlinkClicked event to access the hyperlink end-user clicked.
    For more details please refer: http://help.grapecity.com/componentone/NetHelp/FlexReportUWP/webframe.html#C1.UWP.FlexViewer~C1.Xaml.FlexViewer.C1FlexViewerPane~HyperlinkClicked_EV.html

    Thanks,
    Ruchir
  • Replied 10 September 2018, 11:56 pm EST

    Hello Ruchir,

    ah great, that helped a lot. Some more sophisticated samples would be nice tough - it's a lot searching in api-haystacks ;). But I got it to work.

    For everyone interested, here's my implmentation:

    private void PaneOnHyperlinkClicked(object sender, HyperlinkClickedEventArgs e)
    {
    C1Hyperlink link = e.Hyperlink;
    C1LinkTargetFile file = (C1LinkTargetFile)link.LinkTarget;

    string url = file.FileName;
    // do what you want with it
    }


    I head it cast to C1LinkTargetFile instead C1LinkTargetBase

    And if someone is looling for a e.Handled = true, it's e.Cancel = true for this component.
  • Replied 11 September 2018, 3:06 pm EST

    Hello Andreas,

    Thank you for letting us know that it worked and for sharing the code snippet here, it would certainly help others over the community.

    Thanks,
    Ruchir
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels