This is a migrated thread and some comments may be shown as answers.

Get mouse location on Click (and zoom + rotatation)

3 Answers 334 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
Mikko
Top achievements
Rank 1
Veteran
Mikko asked on 26 Dec 2020, 05:48 PM

Hi,

We have a solution that users can use either with a Windows solution or with a Web browser.

With your great support, we were able to add PushButtonField to a PDF file with Windows Forms solution.

Is this possible also with Ajax version? To get a mouse location, zoom and information if document is rotated. I'm really bad with Javascript.

Thanks in advance for your great support!

Br. Mikko

 

3 Answers, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 30 Dec 2020, 04:40 PM

Hi Mikko,

I am afraid that the requested behavior exceeds the built-in capabilities of the RadPdfViewer. Achieving the desired with custom implementation might cost significant time and effort. The most complicated task here is transferring the mouse location to its relative position in the Pdf file.

RadPdfViewer is a server-side wrapper of the kendo PdfViewer widget for jQuery and both components heavily rely on the third-party PDF.js library for processing the pdf files on the browser. With that in mind, you may research if the desired is possible with PDF.js and if so you can use it for this custom implementation.

Just as an idea: the approach for achieving the desired should be similar to the one used in WinForms:

  1. Wire and handle the click event over the rendered Html representing the Pdf document in the browser.
  2. Get the mouse location and calculate its relative position inside the Html element representing the Pdf page.
  3. Get a reference to the PdfViewer client-side control object and get the kendo widget, see RadPdfViewer Object
  4. Get the current zoomScale of the pdf viewer by using its API
    JavaScript
    var viewer = $find('<%= RadPdfViewer1.ClientID %>');
    var scale = viewer.kendoWidget.zoomScale;
  5. Pass the coordinates, zoom scale, and page dimensions (orientation) to the server-side using ajaxRequest or a __doPostBack() method.
    Currently the RadPdfViewer 
  6. Implement custom logic for transferring the coordinates passed by the client click to coordinates in the document.
  7. Use the same (or similar) DPL server-side logic, like the one in the WinForms solution, to process the result file.

Note that the steps above are informative and the implementation and maintenance of such a custom solution go beyond our support scope.

We also have Professional Services that can help with custom implementations. These services are separate from the Support License and have their own pricing and billing model.

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Mikko
Top achievements
Rank 1
Veteran
answered on 31 Dec 2020, 05:11 PM

Hi Doncho,

Thank you for your answer and great support.

I think that, when using our solution with a web browser, we convert PDF files as images and use your ImageEditor. With that we can collect location of the mouse, and later convert it to PDF location.

Happy new year!

Mikko

0
Doncho
Telerik team
answered on 05 Jan 2021, 11:21 AM

Thank you for the feedback, Mikko.

Happy new year!

Please do not hesitate to reach out to us in case assistance is needed again.

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfViewer
Asked by
Mikko
Top achievements
Rank 1
Veteran
Answers by
Doncho
Telerik team
Mikko
Top achievements
Rank 1
Veteran
Share this question
or