Pdf Ocr
PDF扫描件转Word文档。支持中文OCR识别,自动裁掉页眉页脚,保留插图,彩色章节封面页保留为图片。使用百度OCR API(免费额度1000次/月)。当用户要求把扫描PDF转成文字/Word时触发。
MIT-0 · Free to use, modify, and redistribute. No attribution required.
⭐ 0 · 1.6k · 30 current installs · 31 all-time installs
MIT-0
Security Scan
OpenClaw
Suspicious
medium confidencePurpose & Capability
The name/description (PDF OCR using Baidu) matches the provided scripts: they render PDF pages, crop header/footer, call Baidu OCR, and produce a .docx. However SKILL.md and skill.json claim behaviors (e.g., server retention of originals, automatic progress saves every 50 pages) that are not present in the scripts, which is an incoherence.
Instruction Scope
SKILL.md instructs running the shipped scripts and documents QPS limits and other behaviors. It also explicitly embeds Baidu API key/secret in the README. The instructions state '原始高清版保留在服务器' and '每50页自动保存一次进度', but the executable scripts perform only local processing and save the final docx at the end (no autosave, no upload). This mismatch could mislead users about where files are stored and what the skill does with input PDFs.
Install Mechanism
No install spec; this is instruction + local Python scripts. Dependencies are common Python libs (pymupdf, python-docx, pillow). No external downloads or archive extraction observed.
Credentials
The skill metadata claims no required env vars, but the code reads BAIDU_API_KEY and BAIDU_SECRET_KEY from environment with defaults set to literal API credentials. Those same credentials are published in SKILL.md. Publishing working API credentials in a public skill is a security/privacy concern (credential leakage, misuse of quota, potential billing/abuse). If the developer intended to include a demo key, it should still be documented as such and not presented as the only credential option.
Persistence & Privilege
The skill does not request persistent/always-on privileges, does not modify other skills, and is not configured to be force-included. It runs local scripts and writes output files to the chosen output directory.
What to consider before installing
This skill's code and docs mostly align with a local PDF→OCR workflow, but there are notable red flags you should address before using it on sensitive files:
- The SKILL.md and scripts include hard-coded Baidu API key/secret. Treat those as leaked credentials: replace them with your own account keys (set via BAIDU_API_KEY and BAIDU_SECRET_KEY env vars) or remove the defaults entirely.
- SKILL.md claims 'original high-resolution copies retained on server' and 'autosave every 50 pages' — the provided scripts do not upload files or autosave. Ask the publisher to clarify where uploads (if any) occur. Do not assume remote storage unless the developer confirms and documents it.
- Because the included credentials could be public, the account’s quota or bills might be abused; consider monitoring or using your own key with limited scope/quotas.
- Test the scripts locally on non-sensitive sample PDFs first. Review and run in an isolated environment. If you need autosave or explicit server behavior, request updated code that implements those features transparently.
- If you don’t want to rely on Baidu, modify the code to use your preferred OCR provider and remove embedded secrets. If you proceed nonetheless, remove the hard-coded keys from distributed files to avoid credential leakage.Like a lobster shell, security has layers — review code before you run it.
Current versionv1.0.0
Download ziplatest
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
SKILL.md
PDF扫描件 OCR 转换技能 📄
配置
- 百度 OCR API Key: vOBOM7tO0lL8cKMJdZy453Ai
- 百度 OCR Secret Key: bib8MvDPTfXXdPz4JyzIyDCvCeKxtpyu
- 免费额度: 1000次/月(1次=1页),592页以内一次免费跑完
- 接口: 通用文字识别(高精度版)
accurate_basic
依赖安装
pip install pymupdf python-docx pillow
使用方法
python3 {baseDir}/scripts/pdf_to_docx.py <PDF路径> [输出目录]
输出文件在 [输出目录]/xxx_全文_ocr.docx,文件较大时用脚本压缩图片:
python3 {baseDir}/scripts/compress_docx.py <docx路径> <输出路径>
处理策略
| 页面类型 | 判断方式 | 处理方式 |
|---|---|---|
| 正文页 | 默认 | 裁掉顶部6%(页眉)+底部4%(页脚),OCR识别文字 |
| 插图页 | OCR无文字输出 | 保留为图片嵌入Word |
| 彩色封面/章节页 | 彩色像素占比>25% | 保留为图片,加灰色标注 |
已知限制
- 图文混排页(图表里有文字):OCR会把图表内文字识别为正文,需人工替换
- 解决:用户找到问题页,告知PDF页码,截图后手动替换
- 白底目录页:不会被自动识别为特殊页,会被OCR识别(效果一般)
- 解决:转换后人工替换目录页为图片
实战案例(《预测之书》592页)
- 处理时间:约20分钟(含0.6s/页间隔)
- 输出原始大小:303MB(嵌入144张图片)
- 压缩后大小:3.4MB(图片降分辨率至600px宽,质量60%)
- 识别效果:正文准确率高,图表页需人工处理
- 每50页自动保存一次进度,防止中途崩溃
注意事项
- 免费版 QPS=2,脚本已加0.6秒/页间隔
- 裁剪比例(页眉6%/页脚4%)可在脚本顶部调整
- OCR完成后建议抽查几页校对准确率
- 原始高清版保留在服务器,压缩版用于分发
Files
4 totalSelect a file
Select a file to preview.
Comments
Loading comments…
