Skip to main content

llama-index-readers-pdfluent

A LlamaIndex reader for PDFluent. It reads a PDF with PDFluent's structured extraction and hands LlamaIndex one Document per paragraph, heading, list item or table, in reading order, with the page and box each came from in its metadata so an answer can cite its source.

Install

pip install llama-index-readers-pdfluent

It needs Python 3.9 or later and pdfluent 1.1.0 or later, which pip pulls in automatically. It also depends on llama-index-core (MIT).

Use

Blocks mode

One document per block, a table as one document, in reading order:

from llama_index.core import VectorStoreIndex
from llama_index.readers.pdfluent import PDFluentReader

documents = PDFluentReader().load_data("report.pdf")
index = VectorStoreIndex.from_documents(documents)

print(documents[0].text)
print(documents[0].metadata["page"])
print(documents[0].metadata["bbox"])
print(documents[0].metadata["kind"])

Markdown mode

One document per page, as markdown:

from llama_index.core import VectorStoreIndex
from llama_index.readers.pdfluent import PDFluentReader

documents = PDFluentReader(mode="markdown").load_data("report.pdf")
index = VectorStoreIndex.from_documents(documents)

print(documents[0].text[:200])
print(documents[0].metadata["page"])
print(documents[1].metadata["page"])
print(documents[1].text[:200])

Every PDF in a directory

from llama_index.core import SimpleDirectoryReader
from llama_index.readers.pdfluent import PDFluentReader

documents = SimpleDirectoryReader(
    "./reports", file_extractor={".pdf": PDFluentReader()}
).load_data()

Options:

Argument Default What it does
mode "blocks" "blocks": one document per block, a table as one document. "markdown": one document per page.
include_furniture False Keep the running heads and page numbers a document repeats on every page.
first_page, page_count 0, None Read a window of pages.

Metadata

Key Value
source the path the PDF was read from
page 0-based page index
kind paragraph, heading, list_item, table, header, footer; page in markdown mode
bbox [x0, y0, x1, y1] in points, origin at the bottom left of the page, y up (blocks mode)
confidence the learned model's probability for kind, only where a model decided it
section the last heading above the chunk
level a heading's level, 1 to 3
continues_previous True on the second half of a paragraph a page break cut in two
toc_items the outline entries pointing at the page, as [level, title, page] triples (markdown mode)
tables one {"bbox", "rows", "columns"} per table on the page (markdown mode)

bbox, confidence, level and continues_previous are excluded from the text the embedding model and the LLM see; they are for citing and highlighting. extra_info (and the file metadata SimpleDirectoryReader adds) is merged into every document.

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.

Metadata

Release files for llama-index-readers-pdfluent 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-readers-pdfluent 0.1.0
File Size Uploaded Provenance
llama_index_readers_pdfluent-0.1.0.tar.gz 21.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-readers-pdfluent 0.1.0
File Interpreter ABI Platform
llama_index_readers_pdfluent-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 42.8 kB

Release files / llama_index_readers_pdfluent-0.1.0.tar.gz

Download URL llama_index_readers_pdfluent-0.1.0.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d66f8a1a82bc9eae8bc508dab23f65e0d4709b9be415b4c5fb6a5ffc0bd709f0
BLAKE2b-256 checksum
How to use checksums
b4a3d68c1334ae2b19f76d1f49c5d4c8444ad9ceecd0cefc25c18a97141ce2a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / llama_index_readers_pdfluent-0.1.0-py3-none-any.whl

Download URL llama_index_readers_pdfluent-0.1.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
515c56c6fc0c62d300f724d7c0ac585a9940ddeb2bca931440d7705f5ddee869
BLAKE2b-256 checksum
How to use checksums
cda19ec47327dacd7fa51c9607c0e9a1922480be3ddda3a99f3ecbb74c13fc00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for llama-index-readers-pdfluent 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page