← Back to Skills Marketplace
redfox-data

PDF和图片文字提取

by RedFox · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
31
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install pdf-image-text-extractor
Description
从图片或 PDF 文档中识别并提取文字内容,支持多种图片格式和 PDF 文件,自动判断是否包含文字并保留原始格式输出结构化结果;当用户需要从图片或 PDF 提取文字、进行 OCR 识别、处理含文字的文档或转换为可编辑文本时使用
README (SKILL.md)

文档文字提取器

任务目标

  • 本 Skill 用于:从用户上传的图片或 PDF 文档中识别并提取文字内容
  • 能力包含:图片文字检测、PDF 文字提取、格式保留、结构化输出、Markdown 文件生成
  • 触发条件:用户上传图片或 PDF 并要求提取文字,或询问文档中的文字内容

前置准备

依赖说明

脚本所需的依赖包及版本:

pymupdf>=1.23.0

安装命令:

pip install pymupdf>=1.23.0

支持的文件格式

  • 图片格式:PNG、JPG、JPEG、GIF、WebP、BMP 等常见格式
  • 文档格式:PDF(支持扫描版和文字版)

操作步骤

标准流程

图片文字提取流程

  1. 接收图片

    • 确认用户已上传图片文件
    • 获取图片的访问 URL
  2. 识别图片内容

    • 使用 read_image 工具识别图片内容
    • 在 prompt 中明确要求识别所有文字内容,包括标题、正文、注释、水印等
  3. 判断文字存在性

    • 如果检测到文字:进入步骤 4
    • 如果未检测到文字:告知用户"图片中未包含可提取的文字",任务结束
  4. 提取并整理文字

    • 提取图片中的所有文字内容
    • 保持原有的结构和排版
    • 整理为易读的格式

PDF 文字提取流程

  1. 接收 PDF 文件

    • 确认用户已上传 PDF 文件
    • 获取 PDF 文件的本地路径
  2. 调用脚本提取文字

    • 执行命令:python scripts/pdf_text_extractor.py \x3Cpdf_file_path>
    • 脚本会自动提取所有页面的文本
    • 尽量保留原文的段落结构和标题层级
  3. 处理提取结果

    • 如果提取成功:进入步骤 4
    • 如果提取失败:告知用户错误信息,任务结束
  4. 格式化输出

    • 脚本返回的文本为 Markdown 格式
    • 可直接展示或保存为文件

统一输出步骤

  1. 生成输出结果
    • 根据用户需求生成 Markdown 文件
    • 包含文件来源、提取状态、文字内容等信息
    • 使用清晰的标题和结构组织内容

可选分支

  • 当用户仅需查看文字内容:直接输出文字,不生成文件
  • 当用户要求保存结果:生成 .md 文件
  • 当图片/PDF 文字模糊或难以识别:说明情况并提供最佳识别结果
  • 当 PDF 包含扫描图片:提示用户该页面为扫描图片,可能需要 OCR 处理

资源索引

  • 必要脚本:见 scripts/pdf_text_extractor.py
    • 用途:从 PDF 文件中提取文本内容并保留格式
    • 参数:PDF 文件路径
    • 输出:JSON 格式结果,包含提取的文本和元信息

注意事项

图片文字提取

  • 识别准确性:文字识别结果受图片清晰度、字体、背景等因素影响,可能存在误差
  • 文字排版:提取时尽量保持原图的文字结构和顺序
  • 多语言支持:支持识别中文、英文等多种语言文字

PDF 文字提取

  • 格式保留:脚本会尽量保留原文的段落结构和标题层级
  • 扫描版 PDF:如果 PDF 是扫描图片,文字可能无法提取,需要告知用户
  • 复杂布局:表格、多栏等复杂布局的提取效果可能不佳
  • 加密 PDF:不支持加密或受密码保护的 PDF 文件

通用注意事项

  • 隐私保护:处理的文件不会被存储,仅在当前会话中使用
  • 文件大小:建议处理小于 50MB 的文件,过大文件可能导致处理缓慢

使用示例

示例 1:图片文字提取

用户操作:上传一张包含文字的图片

智能体处理

  1. 使用 read_image 工具识别图片
  2. 提取文字内容:"所有经历的纠缠 / 还有难过的遗憾 / 都不可能没有意义"
  3. 直接输出提取结果

示例 2:PDF 文字提取并保存

用户操作:上传 PDF 并要求"提取这个 PDF 的文字"

智能体处理

  1. 确认 PDF 文件路径
  2. 执行脚本:python scripts/pdf_text_extractor.py ./document.pdf
  3. 获取提取结果,包含 10 页内容
  4. 生成 Markdown 文件:./extracted_from_pdf.md

示例 3:处理扫描版 PDF

用户操作:上传扫描版 PDF

智能体处理

  1. 执行脚本提取文字
  2. 发现部分页面提取为空
  3. 告知用户:"检测到部分页面可能为扫描图片,文字无法直接提取。建议使用 OCR 工具处理。"
Usage Guidance
Install if you are comfortable letting the agent read the contents of PDFs or images you provide for text extraction. Avoid using it on sensitive documents unless you intend the extracted text to appear in the chat or in a saved Markdown file you requested.
Capability Assessment
Purpose & Capability
The stated purpose is extracting text from user-provided images and PDFs, and the artifacts implement that through image reading guidance and a local PyMuPDF-based PDF text extraction script.
Instruction Scope
Instructions are scoped to user-uploaded files, extraction, formatting, and optional Markdown output; there are no role overrides, hidden commands, broad filesystem searches, or unrelated agent instructions.
Install Mechanism
The only declared dependency is pymupdf>=1.23.0, with no postinstall script, package manager automation beyond a documented pip install command, or bundled binary payloads.
Credentials
Local file reads are limited to the PDF path supplied by the user, and the script validates that the input has a .pdf suffix before extracting text.
Persistence & Privilege
The skill may create a Markdown result file when the user asks to save output, but there is no automatic persistence, background worker, privilege escalation, credential use, or deletion behavior.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install pdf-image-text-extractor
  3. After installation, invoke the skill by name or use /pdf-image-text-extractor
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release with robust text extraction from images and PDF files. - Extracts and recognizes text from uploaded images (PNG, JPG, GIF, WebP, BMP, etc.) and PDF documents (text and scanned types). - Maintains original layout and outputs structured, readable results, including Markdown format. - Automatically determines if files contain extractable text and handles both standard and OCR scenarios. - Informs users when extraction is not possible (e.g., non-text images, scanned PDFs without OCR). - Provides clear status messages and output options, including direct display or Markdown file generation.
Metadata
Slug pdf-image-text-extractor
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is PDF和图片文字提取?

从图片或 PDF 文档中识别并提取文字内容,支持多种图片格式和 PDF 文件,自动判断是否包含文字并保留原始格式输出结构化结果;当用户需要从图片或 PDF 提取文字、进行 OCR 识别、处理含文字的文档或转换为可编辑文本时使用. It is an AI Agent Skill for Claude Code / OpenClaw, with 31 downloads so far.

How do I install PDF和图片文字提取?

Run "/install pdf-image-text-extractor" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is PDF和图片文字提取 free?

Yes, PDF和图片文字提取 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does PDF和图片文字提取 support?

PDF和图片文字提取 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created PDF和图片文字提取?

It is built and maintained by RedFox (@redfox-data); the current version is v1.0.0.

💬 Comments