Metadata-Version: 2.5
Name: langchain-superpdf
Version: 0.1.1
Summary: LangChain document loader for superPDF AI: local PDFs as Markdown with tables, charts as data and OCR.
Project-URL: Homepage, https://superpdf.ai
Project-URL: Documentation, https://superpdf.ai/docs/python/langchain-llamaindex
Project-URL: Repository, https://github.com/arjunprabhulal/superpdf/tree/main/integrations/langchain-superpdf
Project-URL: Issues, https://github.com/arjunprabhulal/superpdf/issues
Project-URL: Changelog, https://github.com/arjunprabhulal/superpdf/blob/main/integrations/langchain-superpdf/CHANGELOG.md
Author-email: Arjun Prabhulal <arjun.prabhulal@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: document-loader,langchain,ocr,pdf,pdf-ai,pdf-to-markdown,rag,superpdf
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: langchain-core<2.0.0,>=1.0.0
Requires-Dist: superpdf<1.0.0,>=0.3.1
Description-Content-Type: text/markdown

# langchain-superpdf

[![PyPI](https://img.shields.io/pypi/v/langchain-superpdf?style=flat-square&color=4338ca)](https://pypi.org/project/langchain-superpdf/) [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-555555?style=flat-square)](https://github.com/arjunprabhulal/superpdf/blob/main/LICENSE)

**[superpdf.ai](https://superpdf.ai) · [Docs](https://superpdf.ai/docs/python/langchain-llamaindex) · [GitHub](https://github.com/arjunprabhulal/superpdf)**

The LangChain document loader for **superPDF AI**: local PDFs as Markdown, page by page, ready for RAG. Headings stay
Markdown headings, tables stay tables, charts drawn in the PDF come out as tables of their values, and scanned pages
are read with OCR in 15 languages. Everything runs on your computer; nothing is uploaded.

## Install

```bash
pip install -U langchain-superpdf
```

Python 3.10 or later on macOS, Linux or Windows. Node.js comes with the package; the first load installs the
superPDF reader (about 220 MB) into your cache folder, once.

## Use

```python
from langchain_superpdf import SuperPDFLoader

docs = SuperPDFLoader("report.pdf").load()  # one Document per page
docs[0].page_content  # "# Quarterly report\n\nRevenue grew in every region…"
docs[0].metadata
# {"source": "report.pdf", "total_pages": 4, "creationdate": "", "creator": "…",
#  "producer": "…", "page": 0, "page_label": "1"}
```

`page` counts from 0 and `page_label` from 1, like LangChain's other PDF loaders.

| Option | Effect |
|---|---|
| `mode="single"` | One Document for the whole PDF, pages joined with `pages_delimiter` |
| `pages="1-3"` | Only these pages |
| `tables="html"` | Tables as HTML, keeping merged header cells |
| `ocr=False` | Skip OCR on scanned pages |
| `timeout=1200` | Seconds before giving up on one PDF (default 600) |

Several files at once: `SuperPDFLoader(["a.pdf", "b.pdf"])`. A folder:

```python
from pathlib import Path

docs = SuperPDFLoader(sorted(Path("papers").glob("**/*.pdf"))).load()
```

PDFs that arrive as bytes, such as uploads, go through the parser:

```python
from langchain_core.documents.base import Blob
from langchain_superpdf import SuperPDFParser

blob = Blob.from_data(pdf_bytes, path="upload.pdf")
docs = list(SuperPDFParser().lazy_parse(blob))
```

## Split by section

```python
from langchain_text_splitters import MarkdownHeaderTextSplitter

splitter = MarkdownHeaderTextSplitter([("#", "title"), ("##", "section")])
chunks = []
for doc in docs:
    for chunk in splitter.split_text(doc.page_content):
        chunk.metadata.update(doc.metadata)  # keep source and page for citations
        chunks.append(chunk)
```

## Agents (LangGraph)

For agents, use superPDF AI's MCP server: its 30 PDF tools (read, tables to Excel, Word export, merge, fill forms,
compare and more) load as LangChain tools through
[langchain-mcp-adapters](https://github.com/langchain-ai/langchain-mcp-adapters) and run in any LangGraph agent. The
tools can only use the folders you pass with `--allow-dir`.

```python
from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient(
    {
        "superpdf": {
            "command": "npx",
            "args": [
                "-y",
                "@superpdf/cli",
                "mcp",
                "--allow-dir",
                "/Users/you/Documents/superPDF",
            ],
            "transport": "stdio",
        }
    }
)
tools = await client.get_tools()
agent = create_agent("anthropic:claude-sonnet-5-5", tools)
```

More, including search with page citations: [superpdf.ai/docs/python/langchain-llamaindex](https://superpdf.ai/docs/python/langchain-llamaindex).

## License

[Apache-2.0](https://github.com/arjunprabhulal/superpdf/blob/main/LICENSE). Part of
[superPDF AI](https://github.com/arjunprabhulal/superpdf).
