pdf

A guide for working with PDF files, which are fixed-layout documents that may contain text, tables, scanned pages, or forms. It recommends tools for extracting, editing, merging, splitting, and filling them.

In plain words
What is it for?
Use it to extract text or tables, run OCR on scans, merge or split pages, add watermarks or annotations, and fill PDF forms.
Why use it?
It helps choose an appropriate method based on whether a PDF has selectable text, tables, or scanned images.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/fareedkhan-dev/claude-code-from-scratch/pdf
Any agent
npx skills add FareedKhan-dev/claude-code-from-scratch --skill pdf
Clone the repo
git clone --depth 1 https://github.com/FareedKhan-dev/claude-code-from-scratch

Made for: Claude Code, Codex.

Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 789 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00032 $0.00789
Opus 5 $0.00016 $0.00394
Sonnet 5 $0.00006 $0.00158
Haiku 4.5 $0.00003 $0.00079

Measured 3d ago against content hash 328d56e1a61e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pdf scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/pdf/SKILL.md · 136 lines

How it starts

The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PDF Skill

When to use this skill

Load when the user asks you to:

  • Extract text or tables from a PDF
  • Merge or split PDF files
  • Fill in a PDF form
  • Add watermarks or annotations
  • Convert PDF to another format
  • Search for content inside a PDF

Library decision tree

Need to extract text from a normal (not scanned) PDF?
    → pdfplumber  (best text + table extraction)

Need to manipulate pages (merge, split, rotate)?
    → pypdf  (formerly PyPDF2)

Need to fill form fields?
    → pypdf  with writer.update_page_form_field_values()

PDF is scanned (images of pages, no selectable text)?
    → pytesseract + pdf2image  (OCR pipeline)

Need to create a PDF from scratch?
    → reportlab  or  fpdf2

Install

pip install pdfplumber pypdf
# For OCR:
pip install pytesseract pdf2image
# Also requires: tesseract-ocr (system package) and poppler-utils

Extract text — pdfplumber

import pdfplumber

with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        if text:
            print(text)

Extract tables — pdfplumber

import pdfplumber

with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        tables = page.extract_tables()
        for table in tables:
            for row in table:
                print(row)

Merge PDFs — pypdf

from pypdf import PdfWriter

writer = PdfWriter()
for filename in ["part1.pdf", "part2.pdf", "part3.pdf"]:
    writer.append(filename)
with open("merged.pdf", "wb") as f:
    writer.write(f)

Split PDF — pypdf

from pypdf import PdfReader, PdfWriter

reader = PdfReader("document.pdf")
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    with open(f"page_{i+1}.pdf", "wb") as f:
        writer.write(f)

Extract specific pages — pypdf

from pypdf import PdfReader, PdfWriter

reader = PdfReader("document.pdf")
writer = PdfWriter()
for page_num in [0, 2, 4]:          # 0-indexed
    writer.add_page(reader.pages[page_num])
with open("selected.pdf", "wb") as f:
    writer.write(f)

Read the full file on GitHub · 136 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 136 lines · 32 tokens per session scan A 328d56e1a61e

Subscribe to this mod's changes

pdf is a skill published in the GitHub repository FareedKhan-dev/claude-code-from-scratch (294 stars, last pushed 5mo ago), licensed MIT. It adds 32 tokens to every session and 789 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.