Skip to content
pdf-textlayer
Esc
↑↓navigate↵open⌘Jpreview
On this page

pdf-textlayer

Add an invisible, searchable text layer to a PDF from OCR JSON. One Rust core, shipped as a CLI, a Python package, and a Node.js package.

Give pdf-textlayer a PDF and the JSON your OCR pipeline wrote for it. It writes a new PDF where every OCR word sits at its bounding box as invisible text (PDF render mode 3). The page looks exactly the same, and Ctrl+F, copy and paste, screen readers, and search indexers now find the words.

lit parse scan.pdf --format json --extract-text-metadata -o parsed.json
pdf-textlayer scan.pdf parsed.json searchable.pdf

Why use it

  • Mixed PDFs come out right. A 200-page contract with two scanned exhibits gets text only on the scanned pages. Native text, embedded fonts, and annotations pass through untouched, and an OCR word that lands on a word the page already has is skipped.
  • Every script is kept. CJK, Cyrillic, Greek, and the rest of the Basic Multilingual Plane are written as real text, with no font to pick.
  • Fast. A 500-page scan with 22,500 OCR boxes takes about 0.4 s. See Benchmarks.
  • No runtime dependencies. Each package is one compiled library.
  • One core, three ways in. The writer is Rust. The CLI, the Python package, and the Node.js package all run the same code, so output is identical across them.

Pick your package

New here? Start with the Quickstart.

Was this page helpful?