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
累計下載
1853
星標
2
全站排名
#4,534
全站前 90% · 「辦公效率」前 83%
平台累計安裝累計下載星標評論
ClawHub ↗4516362-
SkillHub ↗22418532—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

適用於缺少原生文字層的掃描版或圖片型 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 並輸出合併文字

月度資料趨勢

累計下載1853
292113119692026-03 · 累計下載 4082026-05 · 累計下載 10132026-06 · 累計下載 11952026-07 · 累計下載 14452026-08 · 累計下載 15542026-09 · 累計下載 185326-0326-09
星標2
1222026-03 · 星標 12026-05 · 星標 22026-06 · 星標 22026-07 · 星標 22026-08 · 星標 22026-09 · 星標 226-0326-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-091853—2
2026-081554+7.5%2
2026-071445+20.9%2
2026-061195+18.0%2
2026-051013—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),按月更新。口徑說明見資料方法。