Documentation Index
Fetch the complete documentation index at: https://agno-v2-shaloo-ai-support-link.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The PDF Reader processes PDF files synchronously and converts them into documents that can be used with Agno’s knowledge system.
Code
examples/basics/knowledge/concepts/readers/overview/pdf_reader_sync.py
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.pdf_reader import PDFReader
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
# Create a knowledge base with PDF documents
knowledge = Knowledge(
vector_db=PgVector(
table_name="pdf_documents",
db_url=db_url,
)
)
# Add PDF content synchronously
knowledge.insert(
path="cookbook/08_knowledge/testing_resources/cv_1.pdf",
reader=PDFReader(),
)
# Create an agent with the knowledge base
agent = Agent(
knowledge=knowledge,
search_knowledge=True,
)
# Query the knowledge base
agent.print_response(
"What skills does an applicant require to apply for the Software Engineer position?",
markdown=True,
)
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
Install dependencies
uv pip install -U pypdf sqlalchemy psycopg pgvector agno openai
Set environment variables
export OPENAI_API_KEY=xxx
Run PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v pgvolume:/var/lib/postgresql/data \
-p 5532:5432 \
--name pgvector \
agno/pgvector:16
Run Agent
python examples/basics/knowledge/concepts/readers/overview/pdf_reader_sync.py
Params
| Parameter | Type | Default | Description |
|---|
path | Path | Required | Path to PDF file or URL |
split_on_pages | bool | True | Split the PDF into pages |
page_start_numbering_format | Optional[str] | None | Format for page numbering |
page_end_numbering_format | Optional[str] | None | Format for page numbering |
password | Optional[str] | None | Password to unlock the PDF |