Pdf add bookmarks
Add hierarchical bookmarks/outline (章→节→小节) to PDF files. Auto-detects text-based vs scanned PDFs, uses OCR for scanned ones. Supports multiple PDF types (textbook/exam/slides/article) with type-specific heading detection. Smart fallback generates candidate TOC when no headings found. Use when user asks to add bookmarks, outline, table of contents, or navigation structure to a PDF. Triggers on: "add bookmarks", "add outline", "为PDF添加书签", "PDF大纲", "PDF目录", "PDF navigation", or providing a PDF path and asking for bookmarks.From its SKILL.md
npx -y skills add StarryCode-Lang/pdf-add-bookmarksAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.2 KB, 871 tokens by cl100k_base, as published. Nobody here has run it
PDF Add Bookmarks
Add hierarchical bookmarks (章→节→小节) to PDF files. Supports textbooks, exam papers, slides, and articles with type-specific heading detection. Auto-detects text-based vs scanned PDFs, uses OCR (multiprocessing) for scanned ones.
Quick Start
pip install pymupdf pytesseract pillow
python scripts/add_bookmarks.py "file.pdf"
Output: file_with_bookmarks.pdf
PDF Type Support
| Type | Detection | Example Headings |
|---|---|---|
| Textbook | 第X章, X.X, Chapter X | 第3章 顺序表, 2.1 栈 |
| Exam | 20XX年真题, 统考, 试题 | 2024年真题应用题 |
| Slides | 一、, bullet points, short titles | 一、备考策略 |
| Article | Abstract, Introduction, References | 1. Introduction |
| Auto | All patterns combined | — |
Usage Modes
Auto-detect (default)
Script detects PDF type and uses appropriate heading patterns:
python scripts/add_bookmarks.py "file.pdf"
Analyze Mode
OCR all pages, show content summary, generate a suggested TOC file for review:
python scripts/add_bookmarks.py "file.pdf" --analyze
Output: file_suggested_toc.txt (review/edit then use with --toc)
Auto-generate TOC
OCR all pages, analyze content, generate bookmarks automatically:
python scripts/add_bookmarks.py "file.pdf" --generate-toc
TOC File Mode
Import bookmarks from a text file:
python scripts/add_bookmarks.py "file.pdf" --toc toc.txt [--offset N]
TOC format — one entry per line, indentation for hierarchy:
第1章 概述 1
1.1 背景 2
1.1.1 研究现状 3
1.2 目标 10
第2章 方法 15
Force OCR
python scripts/add_bookmarks.py "file.pdf" --force-ocr
All Options
usage: add_bookmarks.py [-h] [-o OUTPUT] [--lang LANG] [--force-ocr]
[--toc TOC] [--offset OFFSET] [--workers WORKERS]
[--analyze] [--generate-toc]
[--type {auto,textbook,exam,slides,article}]
input
positional arguments:
input Input PDF file path
options:
-o, --output Output PDF path (default: *_with_bookmarks.pdf)
--lang LANG Tesseract OCR language (default: chi_sim+eng)
--force-ocr Force OCR mode
--toc TOC TOC text file path (title+page per line)
--offset OFFSET Page offset for TOC mode
--workers WORKERS Number of OCR worker processes
--analyze Analyze PDF: OCR all pages, show content summary,
generate suggested TOC file
--generate-toc Auto-generate TOC by OCR+analyzing all pages,
then add bookmarks
--type PDF type hint (auto/textbook/exam/slides/article)
Dependencies
See references/dependencies.md for cross-platform tesseract + Chinese language data setup.
Required: pymupdf pytesseract pillow + tesseract-ocr system tool.
Multi-Agent Installation
See install/INDEX.md for installation guides for:
- Claude Code — Plugin with
/pdf-add-bookmarkscommand - OpenCode — Agent/skill definition
- Hermes — Skill with SKILL.md
- OpenClaw — Skill config
- Kimi Code — Plugin config
- Other agents — Manual script usage
What ships with it: 23 files
83.5 KB alongside SKILL.md, 6 of them executable
install/
- claude-code/CLAUDE.md2.4 KB
- claude-code/plugin.json1.6 KB
- claude-code/README.md815 B
- INDEX.md1.9 KB
- install.ps1runs6.1 KB
- install.shruns3.0 KB
- kimi-code/README.md1.6 KB
- manual/README.md2.2 KB
- openclaw/README.md1.0 KB
- opencode/opencode-agent.json1.9 KB
- opencode/README.md1.1 KB
references/
- dependencies.md888 B
scripts/
- add_bookmarks.pyruns26.7 KB
tests/
- conftest.pyruns908 B
- fixtures/empty_toc.txt0 B
- fixtures/toc_en.txt143 B
- fixtures/toc_offset.txt54 B
- fixtures/toc.txt146 B
- generate_test_pdfs.pyruns7.1 KB
- test_add_bookmarks.pyruns17.6 KB
- .gitignore132 B
- _meta.json719 B
- README.md5.5 KB