Skip to content

Installation

Natural PDF pulls text, tables, and labeled values out of PDFs with CSS-like selectors and spatial navigation. This page covers what each install gets you and which operations download models.

  • Python 3.10 or newer
  • macOS, Linux, or Windows
Terminal window
pip install natural-pdf

The base install handles digital PDFs — files where the text is selectable, not a scan. It gives you:

  • Open PDFs from a file path, URL, or bytes: PDF("report.pdf")
  • Selectors: page.find('text:contains("Total")'), page.find_all('text:bold')
  • Spatial navigation: .right(), .below(), .above(), .left()
  • Text and table extraction: page.extract_text(), page.extract_table().to_df() (pandas is included)
  • Page rendering: page.show() returns a PIL image you can .save("page.png")
  • Exclusion zones for stripping headers and footers before extraction
  • Checkbox detection (page.detect_checkboxes() — downloads a small model, see the callout below)
  • LLM-based structured extraction against a remote OpenAI-compatible API (the openai client is included; you bring the API key)

Check that it worked:

import natural_pdf
natural_pdf.__version__
'0.7.0'

If the import fails with ModuleNotFoundError, you probably installed into a different environment than the one running your script — run pip show natural-pdf and compare against sys.executable.

Terminal window
pip install "natural-pdf[all]"

natural-pdf[all] is the recommended install for document work. It bundles three extras — ai, export, and quality:

  • airapidocr (the default OCR engine), torch, torchvision, transformers, sentence-transformers, timm, doclayout_yolo, and (on Apple Silicon only) mlx-vlm. This unlocks page.apply_ocr(), local question answering with page.ask(), page.classify(), semantic search with pdf.search(), layout detection with page.analyze_layout(), and local VLM OCR/extraction.
  • exportpikepdf, img2pdf, openpyxl, jupytext, nbformat. This unlocks searchable PDF output (pdf.save_searchable()) and Excel export.
  • qualitypyspellchecker, langdetect. Garble-rate diagnostics for to_llm() output (detects OCR’d or corrupted text layers).

It is a large install — torch alone is over a gigabyte of wheels. If you only work with digital PDFs and never OCR, classify, or ask questions locally, the base install is enough.

You want toYou callExtraInstall
OCR a scanned pagepage.apply_ocr()aipip install "natural-pdf[all]"
Ask questions without an API keypage.ask("What is the total?")aipip install "natural-pdf[all]"
Classify pages or regionspage.classify(["invoice", "receipt"])aipip install "natural-pdf[all]"
Semantic search over pagespdf.search("hazardous materials")aipip install "natural-pdf[all]"
Detect layout regionspage.analyze_layout("yolo")aipip install "natural-pdf[all]"
Run a local VLM (GLM-OCR)page.apply_ocr(engine="glm_ocr")aipip install "natural-pdf[all]"
Save a searchable PDFpdf.save_searchable("out.pdf")exportpip install "natural-pdf[export]"
Flag garbled text layerspage.to_llm() diagnosticsqualitypip install "natural-pdf[quality]"
Use PaddleOCRpage.apply_ocr(engine="paddle")paddle (not in all)pip install "natural-pdf[paddle]"
Use EasyOCRpage.apply_ocr(engine="easyocr")nonepip install easyocr
Use Surya OCRpage.apply_ocr(engine="surya")nonepip install surya-ocr
Use Doctr OCRpage.apply_ocr(engine="doctr")nonepip install python-doctr

paddle is deliberately not part of all: it pins numpy below 2.0 and ships its own runtime, so install it only if you need PaddleOCR.

Not sure what’s installed or why an engine refuses to run?

Terminal window
npdf doctor

It prints each dependency group with an OK/MISS status, the installed versions, and the exact pip install line for anything missing. Feature calls that hit a missing dependency raise with the same install hint.