# Send Extract PDF Text to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "extract-pdf-text",
    "name": "Extract PDF Text",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/ivangdavila/extract-pdf-text",
    "canonicalUrl": "https://clawhub.ai/ivangdavila/extract-pdf-text",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/extract-pdf-text",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=extract-pdf-text",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md",
      "examples.md",
      "ocr.md",
      "troubleshooting.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "extract-pdf-text",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-03T02:00:52.640Z",
      "expiresAt": "2026-05-10T02:00:52.640Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=extract-pdf-text",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=extract-pdf-text",
        "contentDisposition": "attachment; filename=\"extract-pdf-text-1.0.2.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "extract-pdf-text"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/extract-pdf-text"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/extract-pdf-text",
    "downloadUrl": "https://openagent3.xyz/downloads/extract-pdf-text",
    "agentUrl": "https://openagent3.xyz/skills/extract-pdf-text/agent",
    "manifestUrl": "https://openagent3.xyz/skills/extract-pdf-text/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/extract-pdf-text/agent.md"
  }
}
```
## Documentation

### When to Use

Agent needs to extract text from PDFs. Use PyMuPDF (fitz) for fast local extraction. Works with text-based documents, scanned pages with OCR, forms, and complex layouts.

### Quick Reference

TopicFileCode examplesexamples.mdOCR setupocr.mdTroubleshootingtroubleshooting.md

### 1. Install PyMuPDF First

pip install PyMuPDF

Import as fitz (historical name):

import fitz  # PyMuPDF

### 2. Basic Text Extraction

import fitz

doc = fitz.open("document.pdf")
text = ""
for page in doc:
    text += page.get_text()
doc.close()

### 3. Pick the Right Method

PDF TypeMethodText-basedpage.get_text() — fast, accurateScannedOCR with pytesseract — slowerMixedCheck each page, use OCR when needed

### 4. Check for Text Before OCR

def needs_ocr(page):
    text = page.get_text().strip()
    return len(text) < 50  # Likely scanned if very little text

### 5. Handle Errors Gracefully

try:
    doc = fitz.open(path)
except fitz.FileDataError:
    print("Invalid or corrupted PDF")
except fitz.PasswordError:
    doc = fitz.open(path, password="secret")

### Extraction Traps

TrapWhat HappensFixOCR on text PDFSlow + worse accuracyCheck get_text() firstForget to close docMemory leakUse with or doc.close()Assume page orderWrong reading flowUse sort=True in get_text()Ignore encodingGarbled charactersPyMuPDF handles UTF-8

### Scope

This skill provides instructions for using PyMuPDF to extract PDF text.

This skill ONLY:

Gives code examples for PyMuPDF
Explains OCR setup when needed
Troubleshoots common issues

This skill NEVER:

Accesses files without user request
Sends data externally
Modifies original PDFs

### Security & Privacy

All processing is local:

PyMuPDF runs entirely on your machine
No external API calls
No data leaves your system

### Plain Text

text = page.get_text()

### Structured (dict)

blocks = page.get_text("dict")["blocks"]
for b in blocks:
    if b["type"] == 0:  # text block
        for line in b["lines"]:
            for span in line["spans"]:
                print(span["text"], span["size"])

### JSON

import json
data = page.get_text("json")
parsed = json.loads(data)

### Full Example

import fitz

def extract_pdf(path):
    """Extract text from PDF, with OCR fallback for scanned pages."""
    doc = fitz.open(path)
    results = []
    
    for i, page in enumerate(doc):
        text = page.get_text()
        method = "text"
        
        # If very little text, might be scanned
        if len(text.strip()) < 50:
            # OCR would go here (see ocr.md)
            method = "needs_ocr"
        
        results.append({
            "page": i + 1,
            "text": text,
            "method": method
        })
    
    doc.close()
    return {
        "pages": len(results),
        "content": results,
        "word_count": sum(len(r["text"].split()) for r in results)
    }

# Usage
result = extract_pdf("document.pdf")
print(f"Extracted {result['word_count']} words from {result['pages']} pages")

### Feedback

Useful? clawhub star extract-pdf-text
Stay updated: clawhub sync
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: ivangdavila
- Version: 1.0.2
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-03T02:00:52.640Z
- Expires at: 2026-05-10T02:00:52.640Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/extract-pdf-text)
- [Send to Agent page](https://openagent3.xyz/skills/extract-pdf-text/agent)
- [JSON manifest](https://openagent3.xyz/skills/extract-pdf-text/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/extract-pdf-text/agent.md)
- [Download page](https://openagent3.xyz/downloads/extract-pdf-text)