Metadata-Version: 2.5
Name: pdfluent-extract
Version: 0.1.0
Summary: PDF to Markdown, JSON and RAG chunks — fast, local, no system dependencies
Project-URL: Homepage, https://pdfluent.com
Project-URL: Documentation, https://pdfluent.com/docs
Project-URL: Pricing, https://pdfluent.com/sdk/pricing/
Project-URL: Source, https://github.com/pdfluent/pdfluent-sdk
Project-URL: Changelog, https://github.com/pdfluent/pdfluent-sdk/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/pdfluent/pdfluent-sdk/issues
Author-email: "Innovation Trigger B.V." <team@pdfluent.com>
License-Expression: AGPL-3.0-only OR LicenseRef-PDFluent-Commercial
License-File: LICENSE
License-File: LICENSE-COMMERCIAL
Keywords: chunking,docling,langchain,llamaindex,llm,markdown,pdf,pdf-to-text,rag,table-extraction
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.8
Classifier: Programming Language :: Python :: 3.9
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: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Requires-Python: >=3.8
Requires-Dist: pdfluent<2,>=1.1.0
Provides-Extra: langchain
Requires-Dist: langchain-pdfluent>=0.1; extra == 'langchain'
Provides-Extra: llamaindex
Requires-Dist: llama-index-readers-pdfluent>=0.1; extra == 'llamaindex'
Description-Content-Type: text/markdown

# pdfluent-extract

PDF and Office files to Markdown, JSON and RAG chunks, in three calls. It is
pure Python: the engine underneath is
[`pdfluent`](https://pypi.org/project/pdfluent/), which pip pulls in
automatically. There is nothing to compile and no system dependency to
install — on Linux arm64 and Alpine/musl as much as anywhere else, because
`pdfluent` 1.1.0 ships a wheel for every platform in the matrix below.

## Install

```bash
pip install pdfluent-extract
```

It needs Python 3.8 or later and `pdfluent` 1.1.0 or later.

## Use

```python
from pdfluent_extract import to_markdown

print(to_markdown("report.pdf"))
```

`to_markdown` takes a path, `bytes` or a file-like object, and routes PDF and
Office (`.docx`/`.pptx`/`.xlsx`) by magic bytes, not by the extension. `pages`
lists 0-based PDF page indices (`None` for the whole file).

```python
from pdfluent_extract import to_json

doc = to_json("report.pdf")
print(doc["name"], len(doc["texts"]))
```

`to_json` returns the file as a Docling `DoclingDocument`, as a dict — the
same JSON `DoclingDocument.model_validate_json` reads.

## Command line

```console
$ pdfluent-extract report.pdf -o report.md
$ pdfluent-extract report.pdf --format json --pages 1-3 > doc.json
$ cat report.pdf | pdfluent-extract - --format text
```

`--format` is one of `md`, `json`, `chunks` or `text`; `--pages` counts
from 1 (`1-3,5`). Without `-o` (or with `-o -`) the output goes to stdout.

## Chunks for RAG

```python
from pdfluent_extract import to_chunks

for chunk in to_chunks("report.pdf", max_tokens=512):
    print(chunk.metadata["page"], chunk.metadata["section_path"], chunk.text[:80])
```

One chunk per paragraph, heading and list item, and one per table. Every chunk
carries `page`, `section_path` (the enclosing headings) and `bbox` in its
metadata, plus `source` for path inputs. Tables longer than the budget split
by rows with the header repeated. PDF only in v1.

## With LangChain and LlamaIndex

```bash
pip install "pdfluent-extract[langchain]"
```

```python
from langchain_pdfluent import PDFluentLoader

docs = PDFluentLoader("report.pdf").load()
print(docs[0].page_content, docs[0].metadata["bbox"])
```

```bash
pip install "pdfluent-extract[llamaindex]"
```

```python
from llama_index.readers.pdfluent import PDFluentReader

docs = PDFluentReader().load_data("report.pdf")
print(docs[0].text[:200])
```

## Supported platforms

Every platform `pdfluent` 1.1.0 ships a wheel for: macOS (universal2),
Windows x64, Linux x86_64 and arm64 on glibc (manylinux2014) and musl
(musllinux_1_2) — Python 3.8 through 3.13 from one abi3 wheel per platform.

## Quality

`quality="fast"` is the only level in v1; anything else is refused by name.
Further levels (vision/OCR) are designed later.

## Licence

AGPL-3.0 or a commercial licence, at your option; see `LICENSE` and
`LICENSE-COMMERCIAL`. The commercial licence is sold yearly and self-service
at <https://pdfluent.com/sdk/pricing/>.
