Get Page Coordinates of Mouse Click

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    1 posts
    Member since:
    Feb 2015

    Posted 10 Jun Link to this post

    I am sure this is an instance when my ignorance will show through, but I am on a deadline and at my wits end. I am trying to have a text appear in an existing PDF based on a position the end-user clicks on the PDF. I when I provide coordinates I can get the text to appear, but I do not always know the coordinates. For the life of me I cannot figure out how to get the PDF Document Coordinates based on the mouse down event. The idea is I am receiving different documents, but they all contain a blank spot to fill in a Name. That position could be different depending on who is sending the document.

    I am using WinForms and I have found plenty of dead-ends on this process including a suggestion of making a custom provider, but that does not seem to work in WinForms.


    Any suggestions on how to calculate the page coordinates or another alternative that could display a ruler or the like to allow the user to enter measurements that I can then convert.

    Thank you in advance for any help.

  2. Dimitar
    Dimitar avatar
    1415 posts

    Posted 13 Jun Link to this post

    Hi Patrick,

    Thank you for writing.

    The following code snippet shows how you can get the position:
    Private Sub RadPdfViewer1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim element = TryCast(radPdfViewer1.ElementTree.GetElementAtPoint(CType(e, MouseEventArgs).Location), RadFixedPageElement)
        If element IsNot Nothing Then
            Dim mouseLocation = CType(e, MouseEventArgs).Location
            Dim tt = element.TotalTransform
            Dim pointInDoc = tt.TransformPoint(mouseLocation)
        End If
    End Sub

    Could you test this with your documents and let me know how it works on your side?

    I am looking forward to your reply.

    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top