react-pdf-highlighter-plus
  • Locate a piece of text in the PDF and return its precise position — the rects of the exact phrase (sub-item, per-line), not a whole sentence. Use it to turn an external quote / citation into a highlight you can render or scroll to.

    Robust to PDF quirks: matching ignores whitespace (so line-wraps and spacing differences don't matter) and falls back to bounded fuzzy matching for minor differences (hyphenation, OCR, slight paraphrase). Returns the first match (optionally restrict the page range), or null.

    Parameters

    • pdfDocument: PDFDocumentProxy
    • query: string
    • options: {
          fuzzy?: boolean;
          pages?: number[] | "all";
      } = {}
      • Optional fuzzy?: boolean
      • Optional pages?: number[] | "all"

    Returns Promise<null | TextPositionMatch>