Constraint: Public skills are published only by explicit administrator action unless they are tracked third-party market sources. Confidence: high Scope-risk: narrow Directive: Keep private/internal skills out of the public marketplace and preserve normal incremental market Git history. Tested: Marketplace validation passed.
36 lines
2.0 KiB
Markdown
36 lines
2.0 KiB
Markdown
---
|
||
name: pdf
|
||
description: 读取、创建、合并、拆分、旋转、OCR 或填写 PDF 表单,处理简体中文字体与页面预览;适用于 Windows PowerShell 和跨平台终端。
|
||
license: Proprietary. LICENSE.txt has complete terms
|
||
---
|
||
|
||
# PDF 文档
|
||
|
||
先读取 [references/platform.md](references/platform.md),确认中文字体、Python 与实际需要的依赖。PDF 不等于扫描图片,先判断页面是否有可提取文字。
|
||
|
||
| 任务 | 工具 |
|
||
| --- | --- |
|
||
| 文本、页面预览、坐标检查 | PyMuPDF |
|
||
| 合并、拆分、旋转、元数据、加密 | pypdf |
|
||
| 表格提取 | pdfplumber,提取后核对表头、合并单元格与换行 |
|
||
| 新建中文 PDF | ReportLab 或可用的 Office/HTML 转 PDF 工具 |
|
||
| 扫描页 OCR | 本机可用的 OCR;Tesseract 中文需 `chi_sim` 数据 |
|
||
|
||
## 中文与排版
|
||
|
||
新文档默认简体中文、A4;已有版式或用户指定版式优先。中文必须使用实际可用的中文字体。优先嵌入授权允许的字体;ReportLab 简单文档可注册 `UnicodeCIDFont('STSong-Light')`。复制文本不乱码、渲染无缺字都需检查。
|
||
|
||
OCR 只针对扫描页或提取失败的页面;中文可用 `chi_sim+eng`,未装语言包时报告缺失。OCR 结果需核对数字、单位、姓名与表格关系,不凭猜测补全。
|
||
|
||
## 表单
|
||
|
||
涉及填写时按需读取 [forms.md](forms.md),先判断是否有 AcroForm 字段。可填表单使用随附 `extract_form_field_info.py`、`fill_fillable_fields.py`;非可填表单按页面坐标叠加,并检查原内容与填写区域。不要把签名图片视作数字签名。
|
||
|
||
## 预览与检查
|
||
|
||
```powershell
|
||
python "$skill\scripts\convert_pdf_to_images.py" ".\输入 中文.pdf" ".\preview"
|
||
```
|
||
|
||
此脚本使用 PyMuPDF,无需 Poppler,逐页渲染以避免一次加载整个大文档。合并或拆分后核对页面数量和顺序;填写后检查可见内容、字段值与页面边界。更多提取与转换方案见 [reference.md](reference.md),旧平台专用命令以本地环境指导为准。
|