Example #1
0
 private PDFLibNet.PageLink SearchLink(Point location)
 {
     if (_pdfDoc != null)
     {
         Point           p     = pageViewControl1.PointToClient(location);
         List <PageLink> links = _pdfDoc.GetLinks(_pdfDoc.CurrentPage);
         if (links != null)
         {
             //Search for a link
             foreach (PDFLibNet.PageLink pl in links)
             {
                 //Convert coordinates
                 Point     p1      = Point.Ceiling(_pdfDoc.PointUserToDev(new PointF(pl.Bounds.Left, pl.Bounds.Top)));
                 Point     p2      = Point.Ceiling(_pdfDoc.PointUserToDev(new PointF(pl.Bounds.Right, pl.Bounds.Bottom)));
                 Rectangle linkLoc = new Rectangle(p1.X, p1.Y, p2.X - p1.X, p1.Y - p2.Y);
                 //Translate
                 linkLoc.Offset(-pageViewControl1.CurrentView.X, -pageViewControl1.CurrentView.Y);
                 linkLoc.Offset(pageViewControl1.PageBounds.X, pageViewControl1.PageBounds.Y);
                 linkLoc.Offset(0, p2.Y - p1.Y);
                 if (linkLoc.Contains(p))
                 {
                     //Link found!
                     return(pl);
                 }
             }
         }
     }
     return(null);
 }