百度OCR云端智能文档解析
简介
百度PaddleOCR文档解析API封装,支持PDF/图片的同步与异步OCR识别,输出结构化Markdown格式,覆盖110+语言
原始描述
Parse documents using PaddleOCR's API. Supports both sync and async modes for images and PDFs.
通过你的 Agent 添加
点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。
或者手动安装
包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。
技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。
中文使用说明 来自收录源
PaddleOCR文档解析技能综合评估
核心用法
本技能是百度PaddleOCR文档解析API的命令行封装工具,专为AI Agent场景设计。用户可通过Shell脚本或Python直接调用,支持两种工作模式:同步模式适用于小文件快速处理(<10MB图片/单页PDF),600秒内返回结果;异步模式针对大体积PDF、多页文档及批量处理场景,提供任务轮询机制获取最终解析结果。
支持输入源包括本地文件路径(JPG/PNG/BMP/TIFF/PDF)和远程URL,输出为结构化JSON,核心字段包含prunedResult(版面元素坐标与分类)和markdown(保留格式的Markdown文本)。内置layout分析能力,可自动识别文本块、表格、公式等版面元素。
显著优点
- 多语言覆盖:原生支持110+种语言,包括中文、英文、日文、阿拉伯文等复杂文字系统
- 版面还原度高:区别于纯文本OCR,保留标题层级、表格结构、段落格式,直接输出可用Markdown
- 双模式灵活:同步模式响应快,异步模式支持大文件,满足不同吞吐量需求
- 百度生态背书:PaddleOCR作为GitHub 42k+ Stars的开源项目,其云端API版本持续迭代
- 零本地算力:纯API调用,无需本地GPU,适合终端设备轻量化部署
潜在局限与风险
- 网络依赖:所有处理均依赖百度AI Studio云服务,离线场景完全不可用
- 配额与成本:需申请Access Token,存在API调用频次和流量限制,商业使用需关注计费策略
- 数据隐私:敏感文档需上传至百度云端处理,存在合规性考量
- 环境配置门槛:需同时配置
PADDLEOCR_ACCESS_TOKEN、PADDLEOCR_API_URL及可选的PADDLEOCR_JOB_URL,多环境变量管理较繁琐 - 错误处理简化:脚本仅返回退出码1和错误文本,缺乏细粒度错误分类与重试机制
- 平台限制:仅支持macOS和Linux,Windows环境未声明兼容
适合人群
- 需要将扫描件/PDF转为可编辑结构化文本的开发者
- 构建RAG(检索增强生成)知识库,需要高质量版面解析结果的AI应用
- 多语言文档处理场景(如跨境电商、国际合同)的自动化工作流
- 无本地GPU资源、倾向云API方案的小团队或个人用户
常规风险提示
| 风险类型 | 说明 |
|---|---|
| 数据主权 | 文档内容上传至百度服务器,涉及跨境数据需评估合规 |
| API可用性 | 依赖百度AI Studio服务SLA,存在单点故障风险 |
| Token泄露 | Access Token硬编码或环境变量暴露可能导致配额盗用 |
| 解析准确性 | 手写体、低质量扫描件、复杂排版可能出现识别错误,需人工校验 |
技能正文
name: paddleocr-doc-parsing description: Parse documents using PaddleOCR's API. Supports both sync and async modes for images and PDFs. homepage: https://www.paddleocr.com metadata: { "openclaw": { "emoji": "📄", "os": ["darwin", "linux"], "requires": { "bins": ["curl", "base64", "jq", "python3"], "env": ["PADDLEOCR_ACCESS_TOKEN", "PADDLEOCR_API_URL"], }, }, }
PaddleOCR Document Parsing
Parse images and PDF files using PaddleOCR's API. Supports both synchronous and asynchronous parsing modes with structured output.
Resource Links
| Resource | Link |
|---|---|
| Official Website | https://www.paddleocr.com |
| API Documentation | https://ai.baidu.com/ai-doc/AISTUDIO/Cmkz2m0ma |
| GitHub | https://github.com/PaddlePaddle/PaddleOCR |
Key Features
- Multi-format support: PDF and image files (JPG, PNG, BMP, TIFF)
- Two parsing modes:
- Sync mode: Fast response for small files (<600s timeout)
- Async mode: For large files with progress polling
- Layout analysis: Automatic detection of text blocks, tables, formulas
- Multi-language: Support for 110+ languages
- Structured output: Markdown format with preserved document structure
Setup
- Visit PaddleOCR to obtain your API credentials
- Set environment variables:
export PADDLEOCR_ACCESS_TOKEN="your_token_here"
export PADDLEOCR_API_URL="https://your-endpoint.aistudio-app.com/layout-parsing"
# Optional: For async mode
export PADDLEOCR_JOB_URL="https://your-job-endpoint.aistudio-app.com/api/v2/ocr/jobs"
export PADDLEOCR_MODEL="PaddleOCR-VL-1.5"
Usage Examples
Sync Mode (Default)
For small files and quick processing:
# Parse local image
{baseDir}/paddleocr_parse.sh document.jpg
# Parse PDF
{baseDir}/paddleocr_parse.sh -t pdf document.pdf
# Parse from URL
{baseDir}/paddleocr_parse.sh https://example.com/document.jpg
# Save output to file
{baseDir}/paddleocr_parse.sh -o result.json document.jpg
# Verbose output
{baseDir}/paddleocr_parse.sh -v document.jpg
Async Mode
For large files with progress tracking:
# Parse large PDF with async mode
{baseDir}/paddleocr_parse.sh --async large-document.pdf
# Parse from URL with async mode
{baseDir}/paddleocr_parse.sh --async -t pdf https://example.com/doc.pdf
# Save async result to file
{baseDir}/paddleocr_parse.sh --async -o result.json document.pdf
Using Python Script Directly
# Sync mode
python3 {baseDir}/paddleocr_parse.py document.jpg
# Async mode
python3 {baseDir}/paddleocr_parse.py --async-mode document.pdf
# With output file
python3 {baseDir}/paddleocr_parse.py -o result.json --async-mode document.pdf
Response Structure
{
"logId": "unique_request_id",
"errorCode": 0,
"errorMsg": "Success",
"result": {
"layoutParsingResults": [
{
"prunedResult": [...],
"markdown": {
"text": "# Document Title\n\nParagraph content...",
"images": {}
},
"outputImages": [...],
"inputImage": "http://input-image"
}
],
"dataInfo": {...}
}
}
Important Fields:
prunedResult- Contains detailed layout element information including positions, categories, etc.markdown- Stores the document content converted to Markdown format with preserved structure and formatting.
Mode Selection Guide
| Use Case | Recommended Mode |
|---|---|
| Small images (< 10MB) | Sync |
| Single page PDFs | Sync |
| Large PDFs (> 10MB) | Async |
| Multi-page documents | Async |
| Batch processing | Async |
| Quick text extraction | Sync |
Error Handling
The script will exit with code 1 and print error message for:
- Missing required environment variables
- File not found
- API authentication failures
- Invalid JSON responses
- API error codes (non-zero)
Quota Information
See official documentation: https://ai.baidu.com/ai-doc/AISTUDIO/Xmjclapam
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。