Skip to content

API Reference parrot_loaders.pdf

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_loaders.pdf

View source

Class PDFLoader

Advanced PDF Loader using PyMuPDF (fitz).

  • Skips image-only pages.
  • Combines title-only pages with next content page.
  • Preserves tables as text for chatbot/RAG KB usage.
  • Returns a Parrot Document per logical page.
  • Supports chapter-based splitting for markdown output.
Parameter Type Default Description
source Optional[Union[str, Path, List[Union[str, Path]]]] None
tokenizer Union[str, Callable] None
text_splitter Union[str, Callable] None
source_type str 'file'
as_markdown bool False
use_chapters bool False
use_pages bool False
**kwargs {}

Attributes:

Attribute Type Description
extensions List[str]

Method PDFLoader.is_title_only

Check if text looks like a title (short, single line, large font).

is_title_only(text: str, min_len: int = 5, max_len: int = 50) -> bool

Parameter Type Default Description
text str
min_len int 5
max_len int 50

Returns: bool

Method PDFLoader.is_image_only

Return True if the page only contains images (no visible text).

is_image_only(page: fitz.Page) -> bool

Parameter Type Default Description
page fitz.Page

Returns: bool

Method PDFLoader.is_table_like

Naive check: Table if lines have multiple columns (lots of |, tab, or spaces).

is_table_like(text: str) -> bool

Parameter Type Default Description
text str

Returns: bool

Method PDFLoader.extract_table

Attempt to extract table structure, return as markdown if detected, else None.

extract_table(page: fitz.Page) -> Optional[str]

Parameter Type Default Description
page fitz.Page

Returns: Optional[str]

Method PDFLoader.extract_chapters_from_markdown

Extract chapters from markdown text based on headers. Returns list of dicts with 'title' and 'content' keys.

extract_chapters_from_markdown(md_text: str) -> List[dict]

Parameter Type Default Description
md_text str

Returns: List[dict]

Method PDFLoader.extract_pages_from_markdown

Extract pages from markdown text based on page separators. Returns list of dicts with 'title' and 'content' keys.

extract_pages_from_markdown(md_text: str) -> List[dict]

Parameter Type Default Description
md_text str

Returns: List[dict]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally