pdf-editor

pdf-editor is a skill for Claude Code, Codex from yugef3h/leo-skills. It costs 0 tokens per session (2,031 once invoked), scanned A, original, MIT.

A workflow for changing variable text or branding in an existing PDF template while preserving its layout, fonts, colors, lines, and spacing.

In plain words
What is it for?
Use it to replace names, dates, amounts, or branding in PDF forms and templates after analyzing their text and image layers.
Why use it?
It helps edit scanned or text-based PDFs without rebuilding the document’s appearance from scratch.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to replace names, dates, amounts, or branding in PDF forms and templates after analyzing their text and image layers.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/yugef3h/leo-skills/pdf-editor
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.

Any agent
npx skills add yugef3h/leo-skills --skill pdf-editor
Clone the repo
git clone --depth 1 https://github.com/yugef3h/leo-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pdf-editor

README.md
[![agentmods](https://agentmods.dev/badge/skills/yugef3h/leo-skills/pdf-editor/github.svg)](https://agentmods.dev/skills/yugef3h/leo-skills/pdf-editor)
Your own site
<a href="https://agentmods.dev/skills/yugef3h/leo-skills/pdf-editor"><img src="https://agentmods.dev/badge/skills/yugef3h/leo-skills/pdf-editor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pdf-editor

Your own site · 80×15
<a href="https://agentmods.dev/skills/yugef3h/leo-skills/pdf-editor"><img src="https://agentmods.dev/badge/skills/yugef3h/leo-skills/pdf-editor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,031 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.02031
Opus 5 $0.00000 $0.01015
Sonnet 5 $0.00000 $0.00406
Haiku 4.5 $0.00000 $0.00203

Measured 12d ago against content hash f73c79c0a462, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

pdf-editor 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 12d 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-editor/SKILL.md · 169 lines

How it starts

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

PDF 模板改写技能

核心流程

PDF 原件 → 判断材质 → OCR 文本块 → 像素分类 → 关系发现 → doc_definition.json → engine.py → 新 PDF

第 0 步:判断 PDF 材质

import fitz
doc = fitz.open("未知.pdf")
page = doc[0]
blocks = page.get_text("dict")["blocks"]
text_spans = sum(1 for b in blocks for l in b.get("lines",[]) for _ in l["spans"])
images = page.get_images(full=True)
print(f"文字段:{text_spans}  嵌入图:{len(images)}")
情况 处理策略
文字段多(>50)、图片少 文字层主导 → 直接改 PDF 文字流
文字段少(<10)、图片是大图 图片层主导 → 拍平→像素编辑→重建

第 1 步:渲染 + OCR

DPI = 200  # A4@200DPI ≈ 1653x2338,匹配常见扫描件分辨率
mat = fitz.Matrix(DPI/72, DPI/72)
pix = page.get_pixmap(matrix=mat)
img = Image.frombytes("RGB", (pix.width, pix.height), pix.samples)
# → 喂给 OCR(macOS Vision / Tesseract / PaddleOCR)

OCR 产出: text, bbox(x,y,w,h), confidence

第 2 步:文本块分类

2.1 像素特征提取

对每个 OCR 块采样:

  • 颜色: median([p for p in pixels if sum(p) < 600]) — 先过滤白背景再取中位数
  • 粗细: 水平扫描笔画宽度均值 > 4.8px @200DPI → 粗体
  • 字高: bbox 高度(近似)
  • 对齐: x 坐标相对页面中线判断 left/center/right

2.2 分类规则(按优先级)

规则 1: 字号最大 + 页面顶部 → "主标题"
规则 2: 有颜色 + 字号偏大 → "章节标题"
规则 3: x < 100 + 字号偏大 → "章节标题"
规则 4: x 在段落基准线附近 + 常规体 → "正文"
规则 5: 正文区内 + 粗体 + 有颜色 → "填入变量"
规则 6: 正文区内 + 粗体 + 无颜色 → "强调文字"
规则 7: 右对齐 + 页面底部 → "签名区"
规则 8: 有颜色文字 → 检查是否填入变量

第 3 步:关系发现

3.1 下划线检测

下划线 = "纵向孤立 + 横向连续"的暗像素行:

for y in range(y_min, y_max):
    # 上下 2px 少暗像素 → 纵向孤立(不是文字行)
    if above_dark > 200 or below_dark > 200: continue
    # 水平连续暗段 > 80px → 下划线
    runs = find_dark_runs(gray[y], threshold=100, min_length=80)

3.2 标签-变量配对(segments 切分)

沿 x 轴逐像素扫描,颜色或粗细变化处切开:

for x in range(block.x, block.x + block.w, 2):
    color = sample_vertical_stripe(img, x, y, y+h)
    bold = measure_stroke_at(img, x, y, y+h)
    if color_diff(color, prev) > 30 or bold != prev_bold:
        segments.append({ "x0": seg_start, "x1": x, ... })

结果:同一行拆为 [标签]/[变量]/[标签]/[变量]/[标签],每段独立样式。

3.3 缩进层级

所有块 x 坐标 KMeans 聚类(n=5) → section < body < list1 < list2 < indent

Read the full file on GitHub · 169 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. 12d ago First seen · 169 lines · 0 tokens per session scan A f73c79c0a462

Subscribe to this mod's changes

pdf-editor is a skill published in the GitHub repository yugef3h/leo-skills (11 stars, last pushed 4d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,031 tokens. 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.

Related

Other skills, from other repositories

PDF Processing Pro

A PDF-processing workflow for handling forms, extracting tables, and using OCR to turn scanned text into searchable data. It also performs automated data checks using built-in scripts.

anbeime/skill · 76 tokens

law-to-markdown

A legal-document conversion skill for turning PDF, Word, or plain-text regulations into structured Markdown. Markdown is a text format that uses simple symbols for headings and lists.

anbeime/skill · 86 tokens

antinet-doc-parse

A document-processing skill for building RAG systems, which let an AI search a knowledge base before answering. It handles complex PDF, Word, and Excel files and produces structured Markdown and metadata.

anbeime/skill · 79 tokens

doc-parse

A document parser that converts PDFs, PowerPoint files, spreadsheets, and Word files into structured Markdown with metadata and a confidence score.

anbeime/skill · 43 tokens

tutor-setup

Transforms knowledge sources into an Obsidian StudyVault. Two modes: (1) Document Mode — PDF/text/web sources → study notes with practice questions. (2) Codebase Mode — source code project → onboarding vault for new developers. Mode is auto-detected based on project markers in CWD.

bevibing/tutor-skills · 66 tokens

pdf-courseware-to-obsidian

A workflow that turns local PDF or PowerPoint course materials into structured Chinese study notes in an Obsidian vault. Obsidian is a note-taking app that stores linked Markdown files and related images.

PhSeCl/pdf-courseware-to-obsidian · 115 tokens