PDF智能拆分

diegosouzapw2026-10-27查看 376复制 997

智能 PDF 拆分技能。基于内容分析将多页扫描 PDF 文档拆分为独立文件。功能:(1) 将 PDF 转换为高质量图像 (2) 分析并按内容智能命名图像 (3) 自动检测并删除重复页面 (4) 识别并重新排序乱序页面 (5) 按内容将相关图像合并为独立 PDF (6) 生成摘要报告。适用于:债券备案文件、申请材料、合同和协议等需要智能内容...

Download (.md)

📘如何使用这个技能

  1. 1
    复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
  2. 2
    打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
  3. 3
    粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
  4. 4
    直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景

💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。

SKILL.md2636 chars
---
name: pdf-smart-split
description: Intelligent PDF splitting skill. Split multi-page scanned PDF documents into separate files based on content analysis. Features: (1) Convert PDF to high-quality images (2) Analyze and intelligently name images by content (3) Auto-detect and remove duplicate pages (4) Identify and reorder scrambled pages (5) Merge related images into separate PDFs by content (6) Generate summary reports. Use for: bond filing documents, application materials, contracts and agreements that need intelligent content-based splitting.
---

# PDF Smart Split Skill

Split multi-page scanned PDF documents into separate files based on content analysis. Supports duplicate detection, page reordering, and intelligent naming.

## Workflow

### 1. PDF to Images
```python
from pdf2image import convert_from_path
images = convert_from_path(pdf_path, dpi=200, thread_count=4)
```
- DPI=200 for quality
- Multi-threading for speed

### 2. Duplicate Detection
```python
import hashlib
def get_image_hash(path):
    with open(path, 'rb') as f:
        return hashlib.md5(f.read()).hexdigest()
```
- Use MD5 hash comparison
- Record duplicates for summary

### 3. Content Analysis and Naming
Use `view_file` tool to analyze each image:
- File type (cover, content, signature page)
- Document category (application, agreement, statement)
- Page sequence number

Naming format: `sequence_filetype_description.jpg`

### 4. Page Reordering
Analyze content continuity:
- Check table sequence numbers
- Check chapter numbering progression
- Ensure signature pages follow content

Reorder by logical content, not physical order.

### 5. Merge Images to PDF
```python
from PIL import Image
def images_to_pdf(image_paths, output_pdf):
    images = [Image.open(p).convert('RGB') for p in image_paths]
    images[0].save(output_pdf, "PDF", save_all=True, append_images=images[1:])
```
- Merge signature pages with their content
- Combine continuous content into single files

### 6. Generate Summary
Summary should include:
- Source file info (name, original pages)
- Duplicate removal records (if any)
- Page reorder records (if any)
- Split file list (name, original pages, page count, description)
- Output directory paths

## Script Usage

### Full Processing
```bash
python scripts/convert_dedup.py <pdf_path> [output_dir]
python scripts/merge_images.py <image1> <image2> ... <output.pdf>
```

## Output Structure
```
filename_images/     # Intelligently named images
filename_split_PDF/  # Content-grouped PDFs
```

## Requirements
- Install: `pdf2image`, `Pillow`
- Windows needs `poppler`: `conda install -c conda-forge poppler`
来源:skillsdirectory

评论0

登录后参与评论

还没有评论,来抢沙发吧