Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda