跳到正文
Skillpedia
PDF、Word 与幻灯片14k · #11335

pdf-official

它能做什么

这项技能处理多种 PDF 文件,从提取文字到制作新报告和填写表单。适合处理合同、表单、发票和扫描页面的人。

适用场景

  • ✓当你需要从现有 PDF 中提取文字或表格的时候。
  • ✓当你想合并、拆分、旋转或为 PDF 页面添加水印的时候。
  • ✓当你需要填写 PDF 表单,或制作扫描件的可搜索副本的时候。

技能链接

https://github.com/XiaomiMiMo/MiMo-Code/blob/main/packages/cli/src/skill/builtin/.bundle/pdf-official/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/XiaomiMiMo/MiMo-Code/blob/main/packages/cli/src/skill/builtin/.bundle/pdf-official/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想用我的姓名和地址填写这份 PDF 申请表中的表单字段。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会先检查该 PDF,例如页数、加密情况以及是否包含表单字段。然后它会把任务分配到提取、转换、组合或填写,并检查结果。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

PDF skill

An Apache-2.0 toolkit for reading, composing, transforming, and filling PDF files. Written from scratch on top of permissively-licensed open-source libraries (pypdf, pdfplumber, pypdfium2, reportlab, pdf-lib, qpdf) so this can be embedded in commercial projects without special agreement.

Route the task

Pick the sub-guide by the verb of the request.

Task Path Read
Pull text / tables / metadata / images out of an existing PDF Extract extract.md
Combine, carve, rotate, crop, watermark, encrypt, or shrink Transform transform.md
Build a PDF that doesn't exist yet (report, invoice, certificate) Compose compose.md
Fill a form (AcroForm or scanned) Interactive interactive.md
Scanned / image-only PDF (no selectable text) Extract → OCR extract.md §5

If a task mixes several of these, follow the order: probe → plan → extract or compose → validate.

Every path starts with a probe. scripts/survey.py returns page count, whether the file is encrypted, whether it has an AcroForm, and whether page 1 looks like a scan.

First install

Bundled runtime: when the MIMO_PYTHON environment variable is set, skip the installs below — run every command with python3/uv run replaced by "$MIMO_PYTHON" (pypdf/pypdfium2/reportlab/Pillow preinstalled; pip console scripts unavailable, use "$MIMO_PYTHON" -m <module>). A bundled qpdf is exposed as MIMO_QPDF (picked up automatically by the scripts here); invoke it directly as "$MIMO_QPDF" --check file.pdf.

Python-only path (all BSD / MIT / Apache) — covers 95% of tasks:

python3 -m pip install --upgrade pypdf pdfplumber pypdfium2 reportlab Pillow

Add these external binaries only when you actually need them:

# qpdf — merge/split/encrypt/repair, Apache-2.0
brew install qpdf                # macOS
apt-get install -y qpdf          # Debian / Ubuntu

# Tesseract — OCR for scanned PDFs, Apache-2.0
brew install tesseract
python3 -m pip install pytesseract pdf2image
apt-get install -y tesseract-ocr

# Poppler — pdftotext / pdftoppm / pdfimages, GPL-2.0
# Optional. Only install if you accept a GPL dependency at CLI level.
brew install poppler
apt-get install -y poppler-utils

Every script under scripts/ uses argparse. Exit codes: 0 OK · 1 runtime failure · 2 bad arguments · 3 validation failure (apply_values.py / overlay_text.py; sanity_check.py reports findings with exit 1). Any single script can be lifted into another project — none imports from a shared framework.

One-command triage

scripts/survey.py path/to/file.pdf --pretty

Sample output:

{
  "path": "/abs/path/file.pdf",
  "page_count": 12,
  "is_locked": false,
  "form_field_count": 34,
  "looks_scanned": false,
  "metadata": {"Title": "...", "Author": "...", "Producer": "..."}
}

Route by the flags:

  • is_locked: true → unlock first (qpdf --password=… --decrypt). Almost every reader library refuses locked files.
  • form_field_count > 0 → widgets path in interactive.md §1.
  • form_field_count == 0 AND you need to fill it → overlay path in interactive.md §2.
  • looks_scanned: true → skip pypdf text extraction, go straight to OCR (extract.md §5).

Which library for which task

Task Preferred Reason Fallback
Plain text pdftotext -layout fastest, keeps columns pypdf
Positioned text pdfplumber char-level bboxes pypdfium2.get_text
Tables pdfplumber tunable table_settings pandas over manual CSV
Page → image pypdfium2 Apache/BSD, no GPL pdftoppm (GPL)
Merge / carve / rotate pypdf pure Python qpdf --pages (faster on huge files)
Encrypt / repair / linearise qpdf handles broken input pypdf (basic encrypt only)
Compose from scratch reportlab mature, BSD pdf-lib in Node
Fill AcroForm pypdf.update_page_form_field_values preserves widget appearances pdf-lib in Node
Overlay on non-fillable reportlab + pypdf.merge_page two-layer merge, see interactive.md —

Common gotchas

  1. PDF origin is bottom-left, image origin is top-left. Every "off by a few points" bug is one of these two systems misapplied. Coordinate conversion is in one place: [`
常见问题

它能读取扫描的 PDF 吗?

能。它可以对扫描件运行 OCR,使文字变得可搜索。

它能处理加密的 PDF 吗?

能。这项技能涵盖 PDF 的加密和解锁。

它需要特殊软件吗?

这项技能使用 pypdf 等 Python 库,在运行其命令之前需要进行设置。

详情

作者的原始描述

Use this skill whenever a PDF file is being produced, opened, transformed, filled, or read. That includes: extracting text or tables from an existing PDF; combining, carving, rotating, cropping, or watermarking pages; composing a fresh PDF (report, invoice, certificate); filling AcroForm fields or overlaying text onto a non-fillable scanned form; encrypting or unlocking a PDF; running OCR over a scanned document; rendering pages to PNG/JPEG for visual analysis. Trigger on mentions of 'PDF', a filename ending in .pdf, requests like 'turn this into a PDF report', or references to AcroForm / form

repo: XiaomiMiMo/MiMo-Code

热度

GitHub 星标
14k
排名
#11335
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能