npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-pdf-text-search

v0.2.1

Published

Full-text search inside PDFs for React Native, returning normalized match rectangles you can draw as highlights. Native on iOS (PDFKit) and Android (PdfBox-Android).

Readme

react-native-pdf-text-search

Full-text search inside PDF files for React Native. Returns, for every match, the page, the matched text, and normalized rectangles you can draw as highlights.

| Platform | Engine | |----------|--------| | iOS | PDFKit | | Android | PdfBox-Android |

Status

Extracted from a production React Native app, where these modules have been shipping since 2024. The API is new, so it may still change before 1.0.

Install

npm install react-native-pdf-text-search
cd ios && pod install

Contains native code, so it needs a custom dev client — it does not run in Expo Go.

Usage

import { searchPDF } from 'react-native-pdf-text-search';

const { matches } = await searchPDF('/path/to/file.pdf', 'sustainability');

// matches[0] =
// {
//   page: 3,
//   text: 'sustainability',
//   rects: [{ x: 0.12, y: 0.34, width: 0.21, height: 0.02 }]
// }

Options

await searchPDF(path, 'term', {
  caseSensitive: false, // default false
  wholeWord: false,     // default false
  startPage: 1,         // 1-based, inclusive
  endPage: 10,          // 1-based, inclusive
});

Drawing the highlights

rects are normalized 0..1 against the page, origin top-left, one rect per line a match spans. Multiply by the size of the rendered page:

<View style={{ width, height }}>
  <Pdf source={{ uri }} style={{ flex: 1 }} page={page} />
  <View pointerEvents="none" style={StyleSheet.absoluteFill}>
    {matches
      .filter((m) => m.page === page)
      .flatMap((m, i) =>
        m.rects.map((r, j) => (
          <View
            key={`${i}-${j}`}
            style={{
              position: 'absolute',
              left: r.x * width,
              top: r.y * height,
              width: r.width * width,
              height: r.height * height,
              backgroundColor: 'rgba(255,235,59,0.4)',
            }}
          />
        )),
      )}
  </View>
</View>

Because the values are relative, they stay correct at any zoom level or screen size.

Errors

The promise rejects with:

| Code | Meaning | |------|---------| | E_FILE_NOT_FOUND | no file at the given path | | E_OPEN_FAILED | the file is not a readable PDF | | E_SEARCH_FAILED | any other native failure |

Limitations

  • Only PDFs with a text layer. Scanned documents without OCR return no matches.
  • Matches that wrap across lines yield several rects; there is no single bounding box.
  • wholeWord uses alphanumeric boundaries, which suits Latin scripts best.
  • Large documents are searched page by page on a background thread; a very large PDF still takes a few seconds.
  • height differs slightly between platforms: iOS reports the selection line height (PDFKit includes leading), Android the glyph height — roughly half. x, y and width agree to four decimals. Pad the rect vertically if you need identical visuals.

License

MIT