---
name: pdf-office-toolkit
description: "PDF办公工具箱。合并、拆分、旋转、加水印、提取文字/图片/表格、PDF转Word/Excel/图片、加密解密、压缩、OCR识别、页码添加、批量处理。当用户需要处理PDF文件、合并多个PDF、提取PDF内容、PDF格式转换、添加水印、PDF加密解密时触发。"
---

# PDF Office Toolkit

PDF办公全能工具，覆盖日常办公中PDF处理的全部常见需求。

## 核心能力

1. **合并与拆分** - 多PDF合并为一个、按页拆分、按书签拆分
2. **内容提取** - 提取文字、图片、表格数据
3. **格式转换** - PDF转Word/Excel/图片/HTML
4. **页面操作** - 旋转、删除、插入、提取指定页
5. **水印与页码** - 添加文字/图片水印、添加页码
6. **加密解密** - 设置打开密码、权限密码、移除密码
7. **OCR识别** - 扫描件文字识别（中英文）
8. **压缩优化** - 降低PDF文件体积

## 快速开始

### 合并PDF

```bash
python3 scripts/pdf_ops.py merge file1.pdf file2.pdf -o merged.pdf
```

### 拆分PDF

```bash
python3 scripts/pdf_ops.py split input.pdf --pages 1-3,5,7-10 -o split/
```

### 提取文字

```bash
python3 scripts/pdf_ops.py extract-text input.pdf -o text.txt
```

### 添加水印

```bash
python3 scripts/pdf_ops.py watermark input.pdf --text "机密文件" -o watermarked.pdf
```

### 旋转页面

```bash
python3 scripts/pdf_ops.py rotate input.pdf --degrees 90 -o rotated.pdf
```

### 添加页码

```bash
python3 scripts/pdf_ops.py page-number input.pdf -o numbered.pdf
```

### PDF转图片

```bash
python3 scripts/pdf_ops.py to-images input.pdf -o images/
```

### 加密PDF

```bash
python3 scripts/pdf_ops.py encrypt input.pdf --password 123456 -o encrypted.pdf
```

### 解密PDF

```bash
python3 scripts/pdf_ops.py decrypt encrypted.pdf --password 123456 -o decrypted.pdf
```

### OCR识别

```bash
python3 scripts/pdf_ops.py ocr input.pdf -o ocr_result.txt
```

## 依赖安装

```bash
pip install PyPDF2 pdfplumber Pillow reportlab pytesseract
# OCR需要安装tesseract: sudo apt install tesseract-ocr tesseract-ocr-chi-sim
```

## 命令参考

详见 [references/cli-reference.md](references/cli-reference.md)
