<< All versions
Skill v1.0.1
currentAutomated scan100/100shareai-lab/learn-claude-code/pdf
1 files
──Details
PublishedJune 16, 2026 at 07:06 PM
Content Hashsha256:b143723126a9951c...
Git SHA20e7cbb72c66
Bump Typepatch
──Files
Files (1 file, 2.5 KB)
SKILL.md2.5 KBactive
SKILL.md · 114 lines · 2.5 KB
version: "1.0.1" name: pdf description: Process PDF files - extract text, create PDFs, merge documents. Use when user asks to read PDF, create PDF, or work with PDF files.
PDF Processing Skill
You now have expertise in PDF manipulation. Follow these workflows:
Reading PDFs
Option 1: Quick text extraction (preferred)
bash
# Using pdftotext (poppler-utils)pdftotext input.pdf - # Output to stdoutpdftotext input.pdf output.txt # Output to file# If pdftotext not available, try:python3 -c "import fitz # PyMuPDFdoc = fitz.open('input.pdf')for page in doc:print(page.get_text())"
Option 2: Page-by-page with metadata
python
import fitz # pip install pymupdfdoc = 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)
bash
# Using pandocpandoc input.md -o output.pdf# With custom stylingpandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=1in
Option 2: Programmatically
python
from reportlab.lib.pagesizes import letterfrom reportlab.pdfgen import canvasc = canvas.Canvas("output.pdf", pagesize=letter)c.drawString(100, 750, "Hello, PDF!")c.save()
Option 3: From HTML
bash
# Using wkhtmltopdfwkhtmltopdf input.html output.pdf# Or with Pythonpython3 -c "import pdfkitpdfkit.from_file('input.html', 'output.pdf')"
Merging PDFs
python
import fitzresult = 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
python
import fitzdoc = 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