← 返回 Skills 市场
31
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install pdf-image-text-extractor
功能描述
从图片或 PDF 文档中识别并提取文字内容,支持多种图片格式和 PDF 文件,自动判断是否包含文字并保留原始格式输出结构化结果;当用户需要从图片或 PDF 提取文字、进行 OCR 识别、处理含文字的文档或转换为可编辑文本时使用
使用说明 (SKILL.md)
文档文字提取器
任务目标
- 本 Skill 用于:从用户上传的图片或 PDF 文档中识别并提取文字内容
- 能力包含:图片文字检测、PDF 文字提取、格式保留、结构化输出、Markdown 文件生成
- 触发条件:用户上传图片或 PDF 并要求提取文字,或询问文档中的文字内容
前置准备
依赖说明
脚本所需的依赖包及版本:
pymupdf>=1.23.0
安装命令:
pip install pymupdf>=1.23.0
支持的文件格式
- 图片格式:PNG、JPG、JPEG、GIF、WebP、BMP 等常见格式
- 文档格式:PDF(支持扫描版和文字版)
操作步骤
标准流程
图片文字提取流程
-
接收图片
- 确认用户已上传图片文件
- 获取图片的访问 URL
-
识别图片内容
- 使用
read_image工具识别图片内容 - 在 prompt 中明确要求识别所有文字内容,包括标题、正文、注释、水印等
- 使用
-
判断文字存在性
- 如果检测到文字:进入步骤 4
- 如果未检测到文字:告知用户"图片中未包含可提取的文字",任务结束
-
提取并整理文字
- 提取图片中的所有文字内容
- 保持原有的结构和排版
- 整理为易读的格式
PDF 文字提取流程
-
接收 PDF 文件
- 确认用户已上传 PDF 文件
- 获取 PDF 文件的本地路径
-
调用脚本提取文字
- 执行命令:
python scripts/pdf_text_extractor.py \x3Cpdf_file_path> - 脚本会自动提取所有页面的文本
- 尽量保留原文的段落结构和标题层级
- 执行命令:
-
处理提取结果
- 如果提取成功:进入步骤 4
- 如果提取失败:告知用户错误信息,任务结束
-
格式化输出
- 脚本返回的文本为 Markdown 格式
- 可直接展示或保存为文件
统一输出步骤
- 生成输出结果
- 根据用户需求生成 Markdown 文件
- 包含文件来源、提取状态、文字内容等信息
- 使用清晰的标题和结构组织内容
可选分支
- 当用户仅需查看文字内容:直接输出文字,不生成文件
- 当用户要求保存结果:生成
.md文件 - 当图片/PDF 文字模糊或难以识别:说明情况并提供最佳识别结果
- 当 PDF 包含扫描图片:提示用户该页面为扫描图片,可能需要 OCR 处理
资源索引
- 必要脚本:见 scripts/pdf_text_extractor.py
- 用途:从 PDF 文件中提取文本内容并保留格式
- 参数:PDF 文件路径
- 输出:JSON 格式结果,包含提取的文本和元信息
注意事项
图片文字提取
- 识别准确性:文字识别结果受图片清晰度、字体、背景等因素影响,可能存在误差
- 文字排版:提取时尽量保持原图的文字结构和顺序
- 多语言支持:支持识别中文、英文等多种语言文字
PDF 文字提取
- 格式保留:脚本会尽量保留原文的段落结构和标题层级
- 扫描版 PDF:如果 PDF 是扫描图片,文字可能无法提取,需要告知用户
- 复杂布局:表格、多栏等复杂布局的提取效果可能不佳
- 加密 PDF:不支持加密或受密码保护的 PDF 文件
通用注意事项
- 隐私保护:处理的文件不会被存储,仅在当前会话中使用
- 文件大小:建议处理小于 50MB 的文件,过大文件可能导致处理缓慢
使用示例
示例 1:图片文字提取
用户操作:上传一张包含文字的图片
智能体处理:
- 使用
read_image工具识别图片 - 提取文字内容:"所有经历的纠缠 / 还有难过的遗憾 / 都不可能没有意义"
- 直接输出提取结果
示例 2:PDF 文字提取并保存
用户操作:上传 PDF 并要求"提取这个 PDF 的文字"
智能体处理:
- 确认 PDF 文件路径
- 执行脚本:
python scripts/pdf_text_extractor.py ./document.pdf - 获取提取结果,包含 10 页内容
- 生成 Markdown 文件:
./extracted_from_pdf.md
示例 3:处理扫描版 PDF
用户操作:上传扫描版 PDF
智能体处理:
- 执行脚本提取文字
- 发现部分页面提取为空
- 告知用户:"检测到部分页面可能为扫描图片,文字无法直接提取。建议使用 OCR 工具处理。"
安全使用建议
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.
能力评估
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.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install pdf-image-text-extractor - 安装完成后,直接呼叫该 Skill 的名称或使用
/pdf-image-text-extractor触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
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.
元数据
常见问题
PDF和图片文字提取 是什么?
从图片或 PDF 文档中识别并提取文字内容,支持多种图片格式和 PDF 文件,自动判断是否包含文字并保留原始格式输出结构化结果;当用户需要从图片或 PDF 提取文字、进行 OCR 识别、处理含文字的文档或转换为可编辑文本时使用. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 31 次。
如何安装 PDF和图片文字提取?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install pdf-image-text-extractor」即可一键安装,无需额外配置。
PDF和图片文字提取 是免费的吗?
是的,PDF和图片文字提取 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
PDF和图片文字提取 支持哪些平台?
PDF和图片文字提取 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 PDF和图片文字提取?
由 RedFox(@redfox-data)开发并维护,当前版本 v1.0.0。
推荐 Skills