A friendly library for working with PDFs
110
stars
460
commits
Jupyter Notebook
primary language
Aug 1, 2026
updated
A friendly library for working with PDFs, built on top of pdfplumber.
Natural PDF lets you find and extract content from PDFs using simple code that makes sense.
pip install natural-pdf
Need OCR, semantic search, export, or AI-powered extraction? Install what you need:
pip install "natural-pdf[all]" # Recommended feature-complete install
pip install "natural-pdf[export]" # Export helpers only
pip install rapidocr # Default OCR backend
pip install "natural-pdf[paddle]" # PaddleOCR stack
pip install python-doctr # Doctr OCR engine
More details in the installation guide.
natural-pdf[all] is the recommended feature-complete runtime bundle for core features: the default RapidOCR engine, sentence-transformers-based semantic search, QA/extraction dependencies, YOLO layout detection, and export support. It does not install every optional backend. Extra engines such as PaddleOCR and Doctr stay opt-in, and Natural PDF will tell you what to install when you try to use something that is missing.
Check your local setup with:
npdf doctor
from natural_pdf import PDF
# Open a PDF
pdf = PDF('https://github.com/jsoma/natural-pdf/raw/refs/heads/main/pdfs/01-practice.pdf')
page = pdf.pages[0]
# Extract all of the text on the page
page.extract_text()
# Find elements using CSS-like selectors
heading = page.find('text:contains("Summary"):bold')
# Extract content below the heading
content = heading.below().extract_text()
# Examine all the bold text on the page
page.find_all('text:bold').show()
# Exclude parts of the page from selectors/extractors
header = page.find('text:contains("CONFIDENTIAL")').above()
footer = page.find_all('line')[-1].below()
page.add_exclusion(header)
page.add_exclusion(footer)
# Extract clean text from the page ignoring exclusions
clean_text = page.extract_text()
And as a fun bonus, page.viewer() will provide an interactive method to explore the PDF.
Natural PDF offers a range of features for working with PDFs:
page.find('text:bold')).heading.below(), element.select_until(...)).Dive deeper into the features and explore advanced usage in the Complete Documentation.
Natural PDF now exposes its pluggable engines through small helper functions so you rarely have to touch the core registry directly. Two handy entry points:
from natural_pdf.tables import register_table_function
def table_delim(region, *, context=None, **kwargs):
# return a TableResult or list-of-lists
...
register_table_function("table_delim", table_delim)
from natural_pdf.selectors import register_selector_engine
class DebugSelectorEngine:
def query(self, *, context, selector, options):
...
register_selector_engine("debug", lambda **_: DebugSelectorEngine())
Natural PDF sits on top of a lot of fantastic tools and models, some of which are:
460 commits
Jupyter Notebook
60.6%
Python
39.2%
A friendly library for working with PDFs
110
stars
460
commits
Jupyter Notebook
primary language
Aug 1, 2026
updated
A friendly library for working with PDFs, built on top of pdfplumber.
Natural PDF lets you find and extract content from PDFs using simple code that makes sense.
pip install natural-pdf
Need OCR, semantic search, export, or AI-powered extraction? Install what you need:
pip install "natural-pdf[all]" # Recommended feature-complete install
pip install "natural-pdf[export]" # Export helpers only
pip install rapidocr # Default OCR backend
pip install "natural-pdf[paddle]" # PaddleOCR stack
pip install python-doctr # Doctr OCR engine
More details in the installation guide.
natural-pdf[all] is the recommended feature-complete runtime bundle for core features: the default RapidOCR engine, sentence-transformers-based semantic search, QA/extraction dependencies, YOLO layout detection, and export support. It does not install every optional backend. Extra engines such as PaddleOCR and Doctr stay opt-in, and Natural PDF will tell you what to install when you try to use something that is missing.
Check your local setup with:
npdf doctor
from natural_pdf import PDF
# Open a PDF
pdf = PDF('https://github.com/jsoma/natural-pdf/raw/refs/heads/main/pdfs/01-practice.pdf')
page = pdf.pages[0]
# Extract all of the text on the page
page.extract_text()
# Find elements using CSS-like selectors
heading = page.find('text:contains("Summary"):bold')
# Extract content below the heading
content = heading.below().extract_text()
# Examine all the bold text on the page
page.find_all('text:bold').show()
# Exclude parts of the page from selectors/extractors
header = page.find('text:contains("CONFIDENTIAL")').above()
footer = page.find_all('line')[-1].below()
page.add_exclusion(header)
page.add_exclusion(footer)
# Extract clean text from the page ignoring exclusions
clean_text = page.extract_text()
And as a fun bonus, page.viewer() will provide an interactive method to explore the PDF.
Natural PDF offers a range of features for working with PDFs:
page.find('text:bold')).heading.below(), element.select_until(...)).Dive deeper into the features and explore advanced usage in the Complete Documentation.
Natural PDF now exposes its pluggable engines through small helper functions so you rarely have to touch the core registry directly. Two handy entry points:
from natural_pdf.tables import register_table_function
def table_delim(region, *, context=None, **kwargs):
# return a TableResult or list-of-lists
...
register_table_function("table_delim", table_delim)
from natural_pdf.selectors import register_selector_engine
class DebugSelectorEngine:
def query(self, *, context, selector, options):
...
register_selector_engine("debug", lambda **_: DebugSelectorEngine())
Natural PDF sits on top of a lot of fantastic tools and models, some of which are:
460 commits
Jupyter Notebook
60.6%
Python
39.2%