Documentation Index
Fetch the complete documentation index at: https://spacesail.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The PDF Password Reader handles password-protected PDF files, allowing you to process secure documents and convert them into searchable knowledge bases.
Code
examples/concepts/knowledge/readers/pdf_reader_password.py
from agno.agent import Agent
from agno.knowledge.content import ContentAuth
from agno.knowledge.knowledge import Knowledge
from agno.utils.media import download_file
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
download_file(
"https://agno-public.s3.us-east-1.amazonaws.com/recipes/ThaiRecipes_protected.pdf",
"ThaiRecipes_protected.pdf",
)
# Create a knowledge base with simplified password handling
knowledge = Knowledge(
vector_db=PgVector(
table_name="pdf_documents_password",
db_url=db_url,
),
)
knowledge.add_content(
path="ThaiRecipes_protected.pdf",
auth=ContentAuth(password="ThaiRecipes"),
)
# Create an agent with the knowledge base
agent = Agent(
knowledge=knowledge,
search_knowledge=True,
)
agent.print_response("Give me the recipe for pad thai")
Usage
Create a virtual environment
Open the Terminal and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
Install libraries
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/concepts/knowledge/readers/pdf_reader_password.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 |