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

326
Visualizações
How to get selected text/divs in pdf.js?

I am using React + pdf.js. I currently render a PDF page (along w/ its text layer) as follows (this is simplified):

return (
  <>
    <canvas ref={canvasRef} width={width} height={height} />
    {textInfo ? (
      <div
        style={{ width, height }}
        className="PageText"
        dangerouslySetInnerHTML={{ __html: textInfo.html }}
      ></div>
    ) : null}
  </>
);

I'm not sure how to get the selected text. Specifically, I'd like to get the actual text divs that were selected because this would allow me to calculate x/y coordinates & width/height of the selection.

Any ideas?

I tried:

onMouseUp={(e) => {
  console.log("MOUSE UP");
  console.log(e);
}};

as prop to the div with className="PageText", but this fails b/c

  1. If the user releases the mouse outside of the bounds of the text layer it does not trigger
  2. I cannot get a list of the divs that have been highlighted
about 4 years ago · Juan Pablo Isaza
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