Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

327
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda