Skip to content

Choose a document loader

A loader turns a file or stream into page dictionaries for extraction. Each page contains content and may include images, tables, source page numbers or regions. Available fields depend on the parser and input; inspect a representative document before choosing your extraction strategy.

Match the loader to the input

Input or need Start with Setup
Plain text DocumentLoaderTxt Core package
Existing page dictionaries DocumentLoaderData Core package
PDF text layer DocumentLoaderPyPdf pip install pypdf
PDF text, tables and geometry DocumentLoaderPyMuPDF Optional PyMuPDF SDK
PDF table layouts Camelot or Tabula Optional SDK; Tabula also needs Java
Local OCR Tesseract, EasyOCR or Docling Native tools/model assets vary
Images for a vision LLM DocumentLoaderLLMImage Vision-capable extraction model
Managed OCR/document parsing Azure, AWS, Google, Adobe or Mistral Provider SDK and credentials
Spreadsheets Spreadsheet loader Optional spreadsheet dependency
Office formats MarkItDown or Doc2txt Optional parser dependency
Web pages Web loader Playwright browser setup

Optional dependencies are not all installed with the core library. Follow the selected loader's page for supported options and environment requirements. Cloud parsing may upload the source document before the extraction LLM is called.

Inspect the pages

from io import BytesIO
from extract_thinker import DocumentLoaderPyPdf

loader = DocumentLoaderPyPdf()
pages = loader.load("invoice.pdf")
print(pages[0]["content"])

with open("invoice.pdf", "rb") as source:
    from_stream = loader.load(BytesIO(source.read()))

A scanned PDF can have no useful text layer. Use OCR or vision when text extraction alone cannot read the source. Vision rendering does not itself recognize text; it supplies images for the selected model.

Select source pages

On the updated main branch, loaders expose one-based page selection:

pages = loader.load_pages("invoice.pdf", [1, 3])
assert [page["page_number"] for page in pages] == [1, 3]

The generic selection API may load the document before filtering. It is not a guarantee of partial parsing. The MCP PDF service selects pages before rendering. See retrieval when you want to rank pages by a text query before model calls.

Compose additional behavior

Configuration and caching vary by loader. Reusing an instance may reuse cached parsing results; configure its documented cache options when source files change. Consult the individual reference rather than assuming every parser exposes the same options.