We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Mouse coordinates to document coordinates

Thread ID:

Created:

Updated:

Platform:

Replies:

124682 Jun 22,2016 12:33 PM Oct 24,2017 08:45 AM WPF 3
loading
Tags: PdfViewer
Florian
Asked On June 22, 2016 12:33 PM

Hi,

I experimented with the PDFViewer control. I am trying to figure out how to get a coordinate in the document coordinate system from a given mouse coordinate.
My sample PDF's single page has a height of 792 and width of 612. I am not sure, which unit those coordinates are in. I can for sure say, that those don't correlate to pixels as on my screen.
So if I click on the pdf document, the current mouse position shall be converted to a document coordinate. This should be possible regardless of the zoom factor applied to the viewer control and regardless of any "free space" around the actual document in the viewer.

Thanks for your support.
Florian


Sathish Sivakumar [Syncfusion]
Replied On June 23, 2016 09:26 AM

Hi Florian, 
 
We have created the Direct-trac support incident to this forum for further follow up, please login to your direct trac account to know more about details about incident.  
 
  
Regards, 
Sathish 


Amit
Replied On October 23, 2017 09:20 AM

Hi Team,

Is this feature can be achieved, can we get the mouse coordinates on pdf?


Sathish Sivakumar [Syncfusion]
Replied On October 24, 2017 08:45 AM

Hi Amit, 
  
Thank you for your patience.  
  
We have already provided the support for “Finding coordinate of the mouse click over the page in the PDF document” using PdfViewer control in WPF from the Essential Studio Vol 2 2016. 
  
Please find the code snippet to find the coordinate of the mouse click over the page in the PDF document:  
  
Code Snippet:  
  
//Creating PageClicked event to find the coordinate of the mouse click over the page in the PDF document  
pdfViewer.PageClicked += pdfViewer_PageClicked;  
  
//PageClicked event  
void pdfViewer_PageClicked(object sender, Syncfusion.Windows.PdfViewer.PageClickedEventArgs args)  
{  
  
  
}  
  
Note: PageClickedEventArgs contains following Properties  
  
1.       PageIndex : Current index of the page in the PDF document being clicked using Mouse  
2.       Position : Returns the coordinates (in Pixels) of the mouse click over the page in the PDF document  
  
We can convert the pixel coordinate to the document coordinate (i.e. Point) using PdfUnitConvertor class.  
  
Note:  
  
  • The coordinates returned by the PageClicked event does not depend on the zoom factor applied to the PdfViewerControl. 
  • The PageClicked event cannot be triggered if we clicked the mouse on the free space around the page in the PdfViewerControl. 
  
We have also created a simple sample to find the coordinates of the mouse click over the page in the PDF document:  
  
  
Please let us know if you need further assistance.  
  
Regards,  
Sathish  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;