Skip to main content

langchain-pdfmuse

LangChain document loader for pdfmuse — a deterministic PDF/DOCX parser for RAG. Same file in → same Documents out, with exact coordinates, tables and section structure.

pip install langchain-pdfmuse

Usage

from langchain_pdfmuse import PdfmuseLoader

# one Document per page (default)
docs = PdfmuseLoader("report.pdf").load()

# RAG-optimized: one Document per block, with section-aware metadata
elements = PdfmuseLoader("report.pdf", mode="elements").load()
for e in elements:
    print(e.metadata["category"], e.metadata["heading_path"], e.metadata["bbox"])

Modes

mode Documents Best for
"single" the whole file as one quick ingestion
"page" (default) one per page page-level retrieval
"elements" one per block (heading / paragraph / table) RAG — chunk with structure

Metadata (elements mode)

Each Document.metadata carries:

  • source, source_kind (Pdf / Docx)
  • page — 0-based page index
  • category — Title · NarrativeText · Table
  • heading_path — the section breadcrumb, e.g. ["Experience", "Alibaba"]
  • bbox — {x0, y0, x1, y1} on the page (top-left origin, points)

heading_path + bbox let your retriever return "which section, where on the page" — not just a blob of text.

Why deterministic matters for RAG

Non-deterministic extractors make your chunks (and therefore embeddings and eval results) drift between runs. pdfmuse has no probabilistic models in its core path, so your index is reproducible. OCR / layout inference are opt-in backends, kept out of the deterministic core — scanned pages surface a NeedsOcr warning instead of guessing.

MIT OR Apache-2.0 · part of the pdfmuse project.

Metadata

Release files for langchain-pdfmuse 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 langchain-pdfmuse 0.1.0
File Size Uploaded
langchain_pdfmuse-0.1.0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-pdfmuse 0.1.0
File Interpreter ABI Platform
langchain_pdfmuse-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / langchain_pdfmuse-0.1.0.tar.gz

Download URL langchain_pdfmuse-0.1.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
36047ee31c8ac7950411b39667111f7f89b11c59d3e1df85b872ebe33a00fa77
BLAKE2b-256 checksum
How to use checksums
c2724caad1a6f913ac9b2a131d5f3701ea71860ba9c69553a07d21f6739beca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

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

Download URL langchain_pdfmuse-0.1.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0239828a298e4b35de2c6a73ee8145cdc28518a6447baa6deab4acfb30567dc6
BLAKE2b-256 checksum
How to use checksums
50e505622d1d8708d538e5f739c5b2834d24522134fca8182b0ef0d277936705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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