pdfrx_web
    Preparing search index...

    Function usePdfSelection

    • The current text selection.

      range updates synchronously as the user drags, but the text behind it does not exist until the pages it spans have loaded their text. This hook resolves it in the background and reports isResolving meanwhile, so a status bar can show the page range immediately and fill in the text when it arrives.

      Returns PdfSelection

      The current pdf selection state and actions.

      const { text, isEmpty, copy } = usePdfSelection();
      if (isEmpty) return null;
      return <button onClick={() => void copy()}>Copy “{text.slice(0, 20)}…”</button>;