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.
npx skills add yugef3h/leo-skills --skill pdf-editorgit clone --depth 1 https://github.com/yugef3h/leo-skillsWrote 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.
[](https://agentmods.dev/skills/yugef3h/leo-skills/pdf-editor)<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.
<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>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.
| Model | Per session | Once 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 |
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.
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
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.
- 12d ago First seen · 169 lines · 0 tokens per session scan A f73c79c0a462
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.
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.
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.
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.
doc-parse
A document parser that converts PDFs, PowerPoint files, spreadsheets, and Word files into structured Markdown with metadata and a confidence score.
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.
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.