This is regarding UWP PDFNet Sdk. I need to capture an event when a user clicks on an embedded link in a PDF document. I need to capture the embedded link's data as well. Any help would be appreciated.
Got it working with the following code. I referred to this article btw.
private void PDFViewCtrl_PointerPressed(object sender, PointerRoutedEventArgs e)
{
(this.DataContext as ViewerPageViewModel).PDFViewCtrl.SetUrlExtraction(true);
int x = (int)e.GetCurrentPoint(sender as FrameworkElement).Position.X;
int y = (int)e.GetCurrentPoint(sender as FrameworkElement).Position.Y;
//var linkInfo = (this.DataContext as ViewerPageViewModel).PDFViewCtrl.GetLinkAt(x, y);
//string url = linkInfo?.GetUrl();
var annotation = (this.DataContext as ViewerPageViewModel).PDFViewCtrl.GetAnnotAt(x, y);
if (annotation != null)
{
if (annotation.GetAnnotType() == AnnotType.e_Link)
{
pdftron.PDF.Annots.Link link = new pdftron.PDF.Annots.Link(annotation.GetSDFObj());
pdftron.PDF.Action action = link.GetAction();
String uri = action.GetSDFObj().Get("URI").Value().GetAsPDFText();
}
}
}