bilicen700

pdf-ocr-extraction

办公效率v1.0.3
作者:bilicen700更新于 2026-05-11共 4 个版本 · 最新版本发布于 2026-03-19@clawhub_bilicen700/pdf-ocr-extraction
PDF 处理#OCR#PDF

据 AlphaMoat 统计,截至 2026-09,pdf-ocr-extraction 累计下载 1,853 次、获 2 个星标,在全部 5,078 个 AI 技能中排名第 4,534 位,在「办公效率」分类(435 个)中排名第 357 位。

累计安装
224
累计下载
1,853
星标
2
全站排名
#4,534
全站前 90% · 「办公效率」前 83%
平台累计安装累计下载星标评论
ClawHub ↗451,6362-
SkillHub ↗2241,8532—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

适用于缺少原生文本层的扫描版或图片型 PDF:完全免费、不调用第三方 API、无使用限制;原理是把 PDF 页面渲染为高分辨率图片(scale=2)再执行 OCR。依赖:系统二进制 tesseract(含 chi_sim/eng 等语言包)与 Python 包 pypdfium2、pytesseract、Pillow;不要在运行时自动 pip install,依赖应由用户或环境按 metadata 块预装。用法:在临时目录创建 extract.py(用 PdfDocument 遍历页 → bitmap.to_pil() 保存 /tmp/page_i.png → pytesseract.image_to_string(lang='chi_sim+eng') → os.remove 清理 → 拼接全文),再执行 python3 extract.py /path/to/document.pdf。安全约束:临时图片只写 /tmp/ 且提取后立即清理;不要用 shell 动态下载或安装语言包,缺特定语言时通知用户。临时 OCR 图片写入可预测的共享路径可能泄露文档内容,应改用内存 OCR 或私有随机临时目录并在处理后立即删除;缺语言包或语言选项不匹配时 OCR 质量与覆盖率会变差,使用前应装好所需语言包并让 Tesseract 语言选项与文档一致;运行时安装依赖会带来运维与安全不确定性,应在最小权限环境预装 Tesseract、语言包、pypdfium2、pytesseract 与 Pillow。

资料发布于 2026-10-29

可以用来做什么

  • 从扫描版或图片型 PDF 提取可编辑文本
  • 本地离线 OCR,不经第三方 API
  • 整本 PDF 逐页 OCR 并合并全文输出

什么时候用

  • PDF 缺少原生文本层、无法直接复制文字时
  • 本地已装 Tesseract 与 Python 依赖、需要免费且无使用限制的 OCR 时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

提取这份扫描 PDF 的全部文字
把这份图片型 PDF 转成可编辑文本
对整本 PDF 逐页 OCR 并输出合并文本

月度数据趋势

累计下载1,853
2921,1311,9692026-03 · 累计下载 4082026-05 · 累计下载 1,0132026-06 · 累计下载 1,1952026-07 · 累计下载 1,4452026-08 · 累计下载 1,5542026-09 · 累计下载 1,85326-0326-09
星标2
1222026-03 · 星标 12026-05 · 星标 22026-06 · 星标 22026-07 · 星标 22026-08 · 星标 22026-09 · 星标 226-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-091,853—2
2026-081,554+7.5%2
2026-071,445+20.9%2
2026-061,195+18.0%2
2026-051,013—2
2026-03408—1

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

2.6 KB · ClawHub v1.0.3
---
name: pdf-ocr-extractor
description: Extract text from image-based or scanned PDFs using Tesseract OCR.
metadata:
  {
    "openclaw":
      {
        "emoji": "📄",
        "requires": { "bins": ["tesseract", "python3"] },
        "install":
展开全部(共 83 行)
          [
            {
              "id": "tesseract-ocr",
              "kind": "system",
              "package": "tesseract",
              "bins": ["tesseract"],
              "label": "Install Tesseract OCR (requires language packs e.g., tesseract-ocr-chi-sim)"
            },
            {
              "id": "pip-deps",
              "kind": "uv",
              "package": "pypdfium2 pytesseract Pillow",
              "label": "Install Python dependencies (pypdfium2, pytesseract, Pillow)"
            }
          ]
      }
  }
---

# PDF OCR Extractor

Use this skill to extract text from scanned PDFs or image-based PDFs that lack a native text layer. It's completely free, doesn't utilize third-party APIs, and offers unlimited usage. It renders PDF pages to images and runs optical character recognition (OCR).

## Dependencies

This skill requires:
1.  **System Binary**: `tesseract` (along with required language data packs like `chi_sim` or `eng`).
2.  **Python Packages**: `pypdfium2`, `pytesseract`, and `Pillow`.

*Note: Do not run automated `pip install` commands at runtime. Rely on the user or the environment to pre-install the dependencies defined in the metadata block.*

## Quick Start

Create a Python script (e.g., `extract.py`) in a temporary directory to handle the extraction safely:

```python
import pypdfium2 as pdfium
import pytesseract
from PIL import Image
import sys
import os

def extract(pdf_path):
    doc = pdfium.PdfDocument(pdf_path)
    full_text = []
    for i, page in enumerate(doc):
        # Render page to a high-resolution image
        bitmap = page.render(scale=2)
        tmp_img = f"/tmp/page_{i}.png"
        bitmap.to_pil().save(tmp_img)
        
        # Run OCR (assuming English and Simplified Chinese packs are installed)
        text = pytesseract.image_to_string(Image.open(tmp_img), lang='chi_sim+eng')
        full_text.append(text)
        
        # Cleanup temporary file
        os.remove(tmp_img)
        
    return "\n".join(full_text)

if __name__ == "__main__":
    if len(sys.argv) > 1:
        print(extract(sys.argv[1]))
```

Then execute the script:
```bash
python3 extract.py /path/to/document.pdf
```

## Security & Sandbox Constraints
- Write temporary images only to `/tmp/` and clean them up immediately after extraction.
- Do not attempt to dynamically download or install language packs via shell commands; notify the user if a specific language is missing.

「办公效率」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。