Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Get the coordinate of click inside iframe (pdf)

I display pdf documents in an iframe on my website (all documents are stored in the same domain).

I would like users to be able to click in the document to add comments at a specific location. To do this, I am looking for a way to get the coordinate inside of an iframe (when we click).

It does not seem possible... However, there are paid solutions that offer this kind of functionality. Example : https://pdfjs.express/demo So, what process is used?

Thanks for you help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can get the coordinate of a click using the onmousedown event. The event gives you a MouseEvent object that contains the x and y coordinate of the click relative to the view port.

To get the coordinate relative to your iframe you have to subtract offsetLeft and offsetTop

Example

var iframe = document.getElementById("iframe")

onmousedown = function(e) {
    document.getElementById("position").textContent = "Mouse position: " + (e.clientX - iframe.offsetLeft) + " | " + (e.clientY - iframe.offsetTop)
}

Edit

You could use PDF.js and a canvas instead of a simple iframe to better controll the PDF-viewer.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!