[英]How to find user clicks on a link inside a PDF page
To capture the embedded link's data, you would use the following method PDFViewCtrl.GetLinkAt() which will return the information on the link at the X and Y position.要捕获嵌入链接的数据,您将使用以下方法PDFViewCtrl.GetLinkAt()将返回有关 X 和 Y position 的链接的信息。
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();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.