langchain-pdfluent
A LangChain document loader for
PDFluent. It reads a PDF with PDFluent's structured
extraction and hands LangChain 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 langchain-pdfluent
It needs Python 3.9 or later and pdfluent 1.1.0 or later, which pip pulls in
automatically. It also depends on langchain-core (MIT).
Use
Blocks mode
One document per block, a table as one document, in reading order:
from langchain_pdfluent import PDFluentLoader
loader = PDFluentLoader("report.pdf")
docs = loader.load()
print(len(docs), "chunks")
print(docs[0].page_content)
print(docs[0].metadata["page"])
print(docs[0].metadata["bbox"])
print(docs[0].metadata["kind"])
Markdown mode
One document per page, as markdown:
from langchain_pdfluent import PDFluentLoader
loader = PDFluentLoader("report.pdf", mode="markdown")
pages = loader.load()
print(len(pages), "pages")
print(pages[0].page_content[:200])
print(pages[0].metadata["page"])
print(pages[1].metadata["page"])
print(pages[0].metadata["kind"])
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 |
Load a window of pages. |
Metadata
| Key | Value |
|---|---|
source |
the path the PDF was loaded 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, toc_items and tables are lists. A vector store that only accepts
scalar metadata, such as Chroma, needs filter_complex_metadata from
langchain_community over the documents first.
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 langchain-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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| langchain_pdfluent-0.1.0.tar.gz | 21.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_pdfluent-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.9 kB
Release files / langchain_pdfluent-0.1.0.tar.gz
| Download URL | langchain_pdfluent-0.1.0.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01f60bce79833fa36c4f68ac9de0967bcf5334c1874e1bae5e7101f8a76d374c
|
|
BLAKE2b-256 checksum How to use checksums |
a9a30096f60b01629c5a75ac2966e4bf8496a9b0a9b35652c00da7054fb70d89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / langchain_pdfluent-0.1.0-py3-none-any.whl
| Download URL | langchain_pdfluent-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7146db4525ad39d91f49f75fa1818d3ad7b9f01caabfe00cc8ce0bcd82bb02fa
|
|
BLAKE2b-256 checksum How to use checksums |
e88cb73b4b4fa9e1f0095a1ee5401da0482025ba09573e3c58f44629659a8317
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for langchain-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.