Agent skill
Process PDF files - extract text, create PDFs, merge documents. Use when user asks to read PDF, create PDF, or work with PDF files.
Install this agent skill to your Project
npx add-skill https://github.com/shareAI-lab/learn-claude-code/tree/main/skills/pdf
SKILL.md
PDF Processing Skill
You now have expertise in PDF manipulation. Follow these workflows:
Reading PDFs
Option 1: Quick text extraction (preferred)
# Using pdftotext (poppler-utils)
pdftotext input.pdf - # Output to stdout
pdftotext input.pdf output.txt # Output to file
# If pdftotext not available, try:
python3 -c "
import fitz # PyMuPDF
doc = fitz.open('input.pdf')
for page in doc:
print(page.get_text())
"
Option 2: Page-by-page with metadata
import fitz # pip install pymupdf
doc = fitz.open("input.pdf")
print(f"Pages: {len(doc)}")
print(f"Metadata: {doc.metadata}")
for i, page in enumerate(doc):
text = page.get_text()
print(f"--- Page {i+1} ---")
print(text)
Creating PDFs
Option 1: From Markdown (recommended)
# Using pandoc
pandoc input.md -o output.pdf
# With custom styling
pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=1in
Option 2: Programmatically
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello, PDF!")
c.save()
Option 3: From HTML
# Using wkhtmltopdf
wkhtmltopdf input.html output.pdf
# Or with Python
python3 -c "
import pdfkit
pdfkit.from_file('input.html', 'output.pdf')
"
Merging PDFs
import fitz
result = fitz.open()
for pdf_path in ["file1.pdf", "file2.pdf", "file3.pdf"]:
doc = fitz.open(pdf_path)
result.insert_pdf(doc)
result.save("merged.pdf")
Splitting PDFs
import fitz
doc = fitz.open("input.pdf")
for i in range(len(doc)):
single = fitz.open()
single.insert_pdf(doc, from_page=i, to_page=i)
single.save(f"page_{i+1}.pdf")
Key Libraries
| Task | Library | Install |
|---|---|---|
| Read/Write/Merge | PyMuPDF | pip install pymupdf |
| Create from scratch | ReportLab | pip install reportlab |
| HTML to PDF | pdfkit | pip install pdfkit + wkhtmltopdf |
| Text extraction | pdftotext | brew install poppler / apt install poppler-utils |
Best Practices
- Always check if tools are installed before using them
- Handle encoding issues - PDFs may contain various character encodings
- Large PDFs: Process page by page to avoid memory issues
- OCR for scanned PDFs: Use
pytesseractif text extraction returns empty
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
mcp-builder
Build MCP (Model Context Protocol) servers that give Claude new capabilities. Use when user wants to create an MCP server, add tools to Claude, or integrate external services.
code-review
Perform thorough code reviews with security, performance, and maintainability analysis. Use when user asks to review code, check for bugs, or audit a codebase.
agent-builder
Design and build AI agents for any domain. Use when users: (1) ask to "create an agent", "build an assistant", or "design an AI system" (2) want to understand agent architecture, agentic patterns, or autonomous AI (3) need help with capabilities, subagents, planning, or skill mechanisms (4) ask about Claude Code, Cursor, or similar agent internals (5) want to build agents for business, research, creative, or operational tasks Keywords: agent, assistant, autonomous, workflow, tool use, multi-step, orchestration
skill-judge
Evaluate Agent Skill design quality against official specifications and best practices. Use when reviewing, auditing, or improving SKILL.md files and skill packages. Provides multi-dimensional scoring and actionable improvement suggestions.
media-writer
Create platform-native content that resonates with each community's culture. Use when adapting technical content for WeChat, Hacker News, Reddit, Medium, Twitter/X, Dev.to, or LinkedIn. Transforms generic writing into content that feels written BY that community, not AT them.
vibe-coding
Transform an AI agent into a tasteful, disciplined development partner. Not just a code generator, but a collaborator with professional standards, transparent decision-making, and craftsmanship. Use for any development task: building features, fixing bugs, designing systems, refactoring. The human provides vision and decisions. The agent provides execution with taste and discipline.
Didn't find tool you were looking for?