Metadata-Version: 2.4
Name: pdfstract
Version: 1.1.1
Summary: PDFStract - The Extraction and Chunking Layer in Your RAG Pipeline - Available as CLI - WEBUI - API
Author: PDFStract Team
License: MIT
Project-URL: Homepage, https://github.com/aksarav/pdfstract
Project-URL: Documentation, https://aksarav.github.io/pdfstract
Project-URL: Repository, https://github.com/aksarav/pdfstract
Project-URL: Issues, https://github.com/aksarav/pdfstract/issues
Keywords: pdf,extraction,rag,chunking,llm,ai,document
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: General
Requires-Python: <=3.13.3,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiofiles>=24.1.0
Requires-Dist: click>=8.1.0
Requires-Dist: fastapi>=0.116.1
Requires-Dist: jinja2>=3.1.6
Requires-Dist: python-multipart>=0.0.20
Requires-Dist: rich>=13.0.0
Requires-Dist: uvicorn[standard]>=0.35.0
Requires-Dist: loguru>=0.7.2
Requires-Dist: python-magic>=0.4.27
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
Requires-Dist: pymupdf4llm>=0.0.26
Requires-Dist: markitdown[pdf]>=0.1.2
Requires-Dist: pillow>=10.4.0
Requires-Dist: pypdf2>=3.0.1
Requires-Dist: chonkie[all]>=1.0.0
Requires-Dist: pip>=26.0.1
Provides-Extra: standard
Requires-Dist: pytesseract>=0.3.10; extra == "standard"
Requires-Dist: unstructured[pdf]>=0.15.0; extra == "standard"
Requires-Dist: pdf2image>=1.17.0; extra == "standard"
Requires-Dist: langchain-openai>=1.1.8; extra == "standard"
Requires-Dist: langchain_ollama>=1.0.1; extra == "standard"
Requires-Dist: gensim>=4.4.0; extra == "standard"
Requires-Dist: langchain-google-genai>=4.2.1; extra == "standard"
Provides-Extra: advanced
Requires-Dist: marker-pdf>=1.8.1; extra == "advanced"
Requires-Dist: docling>=2.12.0; extra == "advanced"
Requires-Dist: paddleocr[all]>=3.3.2; extra == "advanced"
Requires-Dist: paddlepaddle>=3.2.2; platform_machine != "aarch64" and extra == "advanced"
Requires-Dist: transformers>=4.51.1; extra == "advanced"
Requires-Dist: torch>=2.0.0; extra == "advanced"
Requires-Dist: addict>=2.4.0; extra == "advanced"
Requires-Dist: matplotlib>=3.10.7; extra == "advanced"
Requires-Dist: easydict>=1.13; extra == "advanced"
Provides-Extra: all
Requires-Dist: pdfstract[standard]; extra == "all"
Requires-Dist: pdfstract[advanced]; extra == "all"
Dynamic: license-file

# PDFStract

**The Data Preparation Layer for RAG** — Extract. Chunk. Embed.

[![PyPI](https://img.shields.io/pypi/v/pdfstract)](https://pypi.org/project/pdfstract/)
[![Python](https://img.shields.io/pypi/pyversions/pdfstract)](https://pypi.org/project/pdfstract/)
[![License](https://img.shields.io/github/license/AKSarav/pdfstract)](https://github.com/AKSarav/pdfstract/blob/main/LICENSE)

**One unified API.** Switch between 10+ extraction libraries, 10+ chunking methods, and multiple embedding providers with a single parameter change. Focus on your RAG outcomes, not library dependencies.

## Installation

```bash
pip install pdfstract              # Base - pymupdf4llm, markitdown
pip install pdfstract[standard]    # + OCR (pytesseract, unstructured)
pip install pdfstract[advanced]    # + ML-powered (marker, docling, paddleocr)
pip install pdfstract[all]         # Everything
```

## Python API

```python
from pdfstract import PDFStract

pdfstract = PDFStract()

# Extract
text = pdfstract.convert('document.pdf', library='auto')

# Chunk
chunks = pdfstract.chunk(text, chunker='semantic', chunk_size=512)

# Embed
vectors = pdfstract.embed_texts([c['text'] for c in chunks['chunks']])

# Combined pipelines
result = pdfstract.convert_chunk('document.pdf', library='marker', chunker='token')
result = pdfstract.convert_chunk_embed('document.pdf', embedding='sentence-transformers')
```

### Extract Examples

```python
# Auto-select best available library
text = pdfstract.convert('document.pdf', library='auto')

# Use specific library
text = pdfstract.convert('document.pdf', library='marker')
text = pdfstract.convert('document.pdf', library='docling', output_format='json')

# Batch processing
results = pdfstract.batch_convert('./pdfs', library='pymupdf4llm', parallel_workers=4)

# Async
text = await pdfstract.convert_async('document.pdf', library='marker')
```

### Chunk Examples

```python
# Token-based chunking
chunks = pdfstract.chunk(text, chunker='token', chunk_size=512, chunk_overlap=50)

# Semantic chunking
chunks = pdfstract.chunk(text, chunker='semantic', chunk_size=1024)

# Code-aware chunking
chunks = pdfstract.chunk(code_text, chunker='code')

# Access results
for chunk in chunks['chunks']:
    print(f"Chunk {chunk['chunk_id']}: {chunk['token_count']} tokens")
```

### Embed Examples

```python
# Embed multiple texts
vectors = pdfstract.embed_texts(["First text", "Second text"], model='sentence-transformers')

# Embed single text
vector = pdfstract.embed_text("Hello world", model='openai')

# List available providers
providers = pdfstract.list_available_embeddings()
```

## CLI

```bash
pdfstract convert document.pdf --library marker
pdfstract convert-chunk document.pdf --chunker semantic
pdfstract convert-chunk-embed document.pdf --embedding sentence-transformers
pdfstract batch ./pdfs --parallel 4
```

## What's Included

| Tier | Libraries |
|------|-----------|
| **Base** | pymupdf4llm, markitdown |
| **Standard** | + pytesseract, unstructured |
| **Advanced** | + marker, docling, paddleocr, deepseek |

**Chunkers:** token, sentence, semantic, recursive, code, and more

**Embeddings:** OpenAI, Azure, Google, Ollama, Sentence Transformers

## Documentation

📖 **[pdfstract.com](https://pdfstract.com)** — Full docs, guides, and API reference

**GitHub:** [github.com/aksarav/pdfstract](https://github.com/aksarav/pdfstract) · [Issues](https://github.com/aksarav/pdfstract/issues) · [MIT License](https://github.com/aksarav/pdfstract/blob/main/LICENSE)
