Agent skill

PDF Extraction Fallbacks 7d54a9

by HKUDS in HKUDS/OpenSpace

Multi-fallback PDF extraction with sequential approaches and early failure detection

MITAuto-check passedDocuments & Office

Install PDF Extraction Fallbacks 7d54a9

skills CLI
$ npx skills add HKUDS/OpenSpace --skill pdf-extraction-fallbacks-7d54a9 -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HKUDS/OpenSpace pdf-extraction-fallbacks-7d54a9 --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HKUDS/OpenSpace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/benchmarks/gdpval/skills/pdf-extraction-fallbacks-7d54a9 .claude/skills/pdf-extraction-fallbacks-7d54a9 && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
pdf-extraction-fallbacks-7d54a9
GitHub stars
7.8k
Token cost
~2k tokens
SKILL.md length
271 words
Files
2
Skills in repo
199
Repo updated
First seen
Licence
MIT

At a glance

Multi-fallback PDF extraction with sequential approaches and early failure detection

  • Works in 3 steps: Download with Validation → Sequential Extraction Fallbacks → Content Sanity Check
  • Tasks that involve PDF
  • SKILL.md covers When to Use, Core Workflow, Complete Python Implementation and Failure Detection Checklist, plus 3 more sections
  • Calls curl and pdftotext

What it does

PDF Extraction Fallbacks 7d54a9 is an agent skill from HKUDS/OpenSpace. Multi-fallback PDF extraction with sequential approaches and early failure detection

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file.

It sits in Documents & Office, covering PDF. It works with JavaScript. The repository describes itself as: "OpenSpace: The Skill Management Layer for AI Agents" -- https://open-space.cloud/. The licence is MIT.

When your agent uses it

  • Tasks that involve PDF

Example prompts

  • “/pdf-extraction-fallbacks-7d54a9”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Download with Validation
  2. Sequential Extraction Fallbacks
  3. Content Sanity Check

What it can do on your machine

Read from SKILL.md and the folder at commit 3827781. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • curl
    • pdftotext

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use curl, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

PDF Extraction Fallbacks 7d54a9 loads about 2k tokens when it runs. Until then it costs about 29 tokens; SKILL.md has 271 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~29
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HKUDS/OpenSpace at commit 3827781, republished under its MIT licence (© HKUDS). 271 words, ~1,956 tokens.

Download SKILL.mdSave it as .claude/skills/pdf-extraction-fallbacks-7d54a9/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
pdf-extraction-fallbacks-7d54a9
description
Multi-fallback PDF extraction with sequential approaches and early failure detection

PDF Extraction Fallbacks

This skill provides a robust workflow for extracting text from PDFs when source documents may fail to download or extract due to JavaScript protection, CORS restrictions, or encoding issues.

When to Use

  • Downloading regulatory documents from government/agency websites
  • Extracting text from PDFs that may be JavaScript-protected
  • Handling PDFs with potential CORS or encoding issues
  • When you need reliable text extraction with guaranteed fallbacks

Core Workflow

Step 1: Download with Validation
bash
# Download PDF and immediately validate
curl -L -o document.pdf "URL_HERE"

# Check file size (reject if < 1KB - likely error page)
FILE_SIZE=$(stat -f%z document.pdf 2>/dev/null || stat -c%s document.pdf 2>/dev/null)
if [ "$FILE_SIZE" -lt 1024 ]; then
    echo "FAIL: File too small ($FILE_SIZE bytes) - likely error page"
    # Log the actual content to diagnose
    head -c 500 document.pdf
    exit 1
fi

# Check for HTML/error content instead of PDF
if head -c 500 document.pdf | grep -qi "<!DOCTYPE html\|<html\|error\|access denied"; then
    echo "FAIL: Downloaded HTML/error page instead of PDF"
    exit 1
fi
Step 2: Sequential Extraction Fallbacks

Try extraction methods in order of reliability:

Fallback 1: pdftotext (poppler-utils)

bash
if command -v pdftotext &> /dev/null; then
    pdftotext -layout document.pdf output.txt 2>/dev/null
    if [ -s output.txt ] && [ $(wc -c < output.txt) -gt 100 ]; then
        echo "SUCCESS: pdftotext extraction"
        exit 0
    fi
fi

Fallback 2: PyMuPDF (fitz)

python
import fitz  # PyMuPDF

def extract_with_pymupdf(pdf_path):
    try:
        doc = fitz.open(pdf_path)
        text = ""
        for page in doc:
            text += page.get_text()
        doc.close()
        if len(text.strip()) > 100:
            return text
        return None
    except Exception as e:
        print(f"PyMuPDF failed: {e}")
        return None

Fallback 3: pdfplumber

python
import pdfplumber

def extract_with_pdfplumber(pdf_path):
    try:
        text = ""
        with pdfplumber.open(pdf_path) as pdf:
            for page in pdf.pages:
                page_text = page.extract_text()
                if page_text:
                    text += page_text + "\n"
        if len(text.strip()) > 100:
            return text
        return None
    except Exception as e:
        print(f"pdfplumber failed: {e}")
        return None
Step 3: Content Sanity Check

After any extraction, validate the output:

python
def validate_extraction(text, min_chars=100, min_words=20):
    """Check if extracted text is meaningful content."""
    if not text:
        return False, "Empty extraction"
    
    text = text.strip()
    if len(text) < min_chars:
        return False, f"Too short: {len(text)} chars"
    
    words = text.split()
    if len(words) < min_words:
        return False, f"Too few words: {len(words)}"
    
    # Check for error patterns
    error_patterns = [
        "access denied", "permission denied", "javascript required",
        "failed to load", "cannot display", "corrupted"
    ]
    text_lower = text.lower()
    for pattern in error_patterns:
        if pattern in text_lower[:500]:  # Check beginning
            return False, f"Error pattern detected: {pattern}"
    
    return True, "Valid extraction"

Complete Python Implementation

python
import requests
import subprocess
import os
from pathlib import Path

def robust_pdf_extraction(url, output_path="extracted.txt", temp_pdf="temp.pdf"):
    """
    Multi-fallback PDF extraction with validation at each step.
    Returns (success, text_or_error)
    """
    
    # Step 1: Download with validation
    try:
        response = requests.get(url, timeout=30, headers={
            'User-Agent': 'Mozilla/5.0 (compatible; DocumentExtractor/1.0)'
        })
        response.raise_for_status()
    except Exception as e:
        return False, f"Download failed: {e}"
    
    # Check response size
    if len(response.content) < 1024:
        return False, f"Downloaded content too small: {len(response.content)} bytes"
    
    # Check for HTML error pages
    if response.content[:500].lower().find(b'<html') != -1:
        return False, "Downloaded HTML page instead of PDF"
    
    # Save PDF
    Path(temp_pdf).write_bytes(response.content)
    
    # Step 2: Try extraction methods in order
    extraction_methods = [
        ("pdftotext", extract_pdftotext),
        ("PyMuPDF", extract_pymupdf),
        ("pdfplumber", extract_pdfplumber),
    ]
    
    for method_name, extract_func in extraction_methods:
        try:
            text = extract_func(temp_pdf)
            valid, msg = validate_extraction(text)
            if valid:
                Path(output_path).write_text(text)
                return True, text
            print(f"{method_name}: {msg}")
        except Exception as e:
            print(f"{method_name} exception: {e}")
    
    # Cleanup
    os.remove(temp_pdf)
    return False, "All extraction methods failed"


def extract_pdftotext(pdf_path):
    result = subprocess.run(
        ["pdftotext", "-layout", pdf_path, "-"],
        capture_output=True, text=True, timeout=60
    )
    return result.stdout if result.returncode == 0 else None


def extract_pymupdf(pdf_path):
    import fitz
    doc = fitz.open(pdf_path)
    text = "".join(page.get_text() for page in doc)
    doc.close()
    return text


def extract_pdfplumber(pdf_path):
    import pdfplumber
    text = ""
    with pdfplumber.open(pdf_path) as pdf:
        for page in pdf.pages:
            page_text = page.extract_text()
            if page_text:
                text += page_text + "\n"
    return text

Failure Detection Checklist

CheckThresholdAction
File size< 1KBReject - likely error page
Content typeHTML detectedReject - not a PDF
Extracted text< 100 charsTry next fallback
Word count< 20 wordsTry next fallback
Error patternsFound in first 500 charsReject extraction

Best Practices

  1. Always validate immediately after download - Don't wait until extraction to discover the PDF is invalid
  2. Log each fallback attempt - Helps diagnose which sites need special handling
  3. Set reasonable timeouts - PDF processing can hang on corrupted files
  4. Clean up temp files - Especially important in automated workflows
  5. Preserve original PDFs - Keep copies for debugging extraction failures
  6. Check for JavaScript protection - Some sites require headless browser rendering first

Common Failure Modes

SymptomLikely CauseSolution
92-byte "PDF"JavaScript error pageUse headless browser (Playwright/Selenium)
HTML contentRedirect to login/errorCheck authentication requirements
Empty extractionScan-only PDFUse OCR (pytesseract) as additional fallback
Garbled textEncoding issuesTry different PDF libraries

Integration Example

python
# For regulatory document retrieval workflows
def retrieve_regulatory_doc(doc_url, output_dir="docs"):
    success, result = robust_pdf_extraction(
        doc_url,
        output_path=f"{output_dir}/content.txt",
        temp_pdf=f"{output_dir}/temp.pdf"
    )
    
    if success:
        print(f"✓ Extracted {len(result)} characters")
        return result
    else:
        print(f"✗ Failed: {result}")
        # Log URL for manual review
        with open("failed_urls.log", "a") as f:
            f.write(f"{doc_url}: {result}\n")
        return None

© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in benchmarks/gdpval/skills/pdf-extraction-fallbacks-7d54a9 of HKUDS/OpenSpace.

  • SKILL.md
  • .skill_id

Open the folder on GitHubat commit 3827781

Compare with similar skills

PDF Extraction Fallbacks 7d54a9 next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

PDF Extraction Fallbacks 7d54a9 compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
PDF Extraction Fallbacks 7d54a9 this skillHKUDS/OpenSpace7.8k—~2kAutomated safety check: PassMIT
Jev SEOAgriciDaniel/jev-seo543—~2.5kAutomated safety check: NotesMIT
Analyzing Malicious PDF With Peepdfmukul975/Anthropic-Cybersecurity-Skills34k—~799Automated safety check: PassApache-2.0
PDF Toolkitborghei/Claude-Skills891—~1.4kAutomated safety check: PassMIT
Edit PDFSimplePDF/simplepdf-embed407—~1.5kAutomated safety check: PassMIT
Build With SimplepdfSimplePDF/simplepdf-embed407—~7kAutomated safety check: PassMIT

Similar skills

  • Jev SEO

    AgriciDaniel/jev-seo

    Full live SEO audit of any website from its homepage URL, powered by Jev (TypeSafe's System One model).

    543 GitHub stars~2.5k tokensUpdated 18 days ago
    Documents & OfficeAuto-check: notes
  • Analyzing Malicious PDF With Peepdf

    mukul975/Anthropic-Cybersecurity-Skills

    Perform static analysis of malicious PDF documents using peepdf, pdfid, and pdf-parser to extract embedded JavaScript, shellcode, and suspicious objects.

    34k GitHub stars~799 tokensUpdated 1 mo ago
    Documents & OfficeAuto-check passed
  • PDF Toolkit

    borghei/Claude-Skills

    Audit PDF files for metadata leakage, page count, encryption, JavaScript, embedded files, and version.

    891 GitHub stars~1.4k tokensUpdated 3 days ago
    Documents & OfficeAuto-check passed
  • Edit PDF

    SimplePDF/simplepdf-embed

    Edit and fill PDF documents. An agent skill from SimplePDF/simplepdf-embed.

    407 GitHub stars~1.5k tokensUpdated today
    Documents & OfficeAuto-check passed
  • Build With Simplepdf

    SimplePDF/simplepdf-embed

    Integrate SimplePDF into a web application for PDF viewing, editing, filling, signing, programmatic control, AI-agent interaction, human-in-the-loop form prefilling, submissions, webhooks, or…

    407 GitHub stars~7k tokensUpdated today
    Documents & OfficeAuto-check passed
  • Markitdown

    ImCa0/just-laws

    Convert files and office documents to Markdown. An agent skill from ImCa0/just-laws.

    781 GitHub starsUsed in 14 repos~3.2k tokens
    Documents & OfficeAuto-check: notes

More from HKUDS/OpenSpace

All 199 skills in this repo
  • Walks through producing a master audio track plus stems in Python, from checking a reference file and timing sections by BPM to effects, a zip archive and final verification.

    7.8k GitHub stars~2.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Handle cascading data retrieval tool failures by falling back to embedded knowledge generation

    7.8k GitHub stars~765 tokensUpdated 1 mo ago
    Auto-check passed
  • Gives an agent a workaround when its code-execution sandbox keeps failing: save the Python script to a file and run it through the shell instead.

    7.8k GitHub stars~588 tokensUpdated 1 mo ago
    Auto-check passed
  • A recovery routine for agents whose sandboxed code runner keeps failing: save the Python script to disk, then run it through the shell and read the output.

    7.8k GitHub stars~652 tokensUpdated 1 mo ago
    Auto-check passed
  • Fallback ladder for failed sandboxed code runs, plus the habit of fixing the working directory first so generated files land in the right place.

    7.8k GitHub stars~1.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Fallback workflow for executing Python code when executecodesandbox fails repeatedly

    7.8k GitHub stars~1.1k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about PDF Extraction Fallbacks 7d54a9

What does PDF Extraction Fallbacks 7d54a9 do?

Multi-fallback PDF extraction with sequential approaches and early failure detection. PDF Extraction Fallbacks 7d54a9 is an agent skill from HKUDS/OpenSpace.

When should I use PDF Extraction Fallbacks 7d54a9?

PDF Extraction Fallbacks 7d54a9 fits situations like: tasks that involve PDF.

How do I install PDF Extraction Fallbacks 7d54a9 in Claude Code?

Run `npx skills add HKUDS/OpenSpace --skill pdf-extraction-fallbacks-7d54a9 -a claude-code`. Or copy the skill folder (benchmarks/gdpval/skills/pdf-extraction-fallbacks-7d54a9 in HKUDS/OpenSpace) into .claude/skills/pdf-extraction-fallbacks-7d54a9 in your project. Claude Code loads it when a task matches its description.

How do I install PDF Extraction Fallbacks 7d54a9 in Codex?

Run `npx skills add HKUDS/OpenSpace --skill pdf-extraction-fallbacks-7d54a9 -a codex`. Or copy the skill folder (benchmarks/gdpval/skills/pdf-extraction-fallbacks-7d54a9 in HKUDS/OpenSpace) into .agents/skills/pdf-extraction-fallbacks-7d54a9 in your project. Codex loads it when a task matches its description.

Can I use PDF Extraction Fallbacks 7d54a9 in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/OpenSpace --skill pdf-extraction-fallbacks-7d54a9 -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/pdf-extraction-fallbacks-7d54a9, .gemini/skills/pdf-extraction-fallbacks-7d54a9, .github/skills/pdf-extraction-fallbacks-7d54a9 and .opencode/skills/pdf-extraction-fallbacks-7d54a9 in your project.

What does PDF Extraction Fallbacks 7d54a9 need to run?

Going by SKILL.md and its folder, PDF Extraction Fallbacks 7d54a9 needs the command-line tools its instructions call (curl and pdftotext). Our summary lists: Python 3.

Does PDF Extraction Fallbacks 7d54a9 access the network?

SKILL.md contains no URLs. Its commands use curl, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is PDF Extraction Fallbacks 7d54a9 safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does PDF Extraction Fallbacks 7d54a9 use?

PDF Extraction Fallbacks 7d54a9 is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does PDF Extraction Fallbacks 7d54a9 use?

About 2k tokens (SKILL.md is roughly 7.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to PDF Extraction Fallbacks 7d54a9?

Skills that share tags, products or a category with PDF Extraction Fallbacks 7d54a9: Jev SEO (AgriciDaniel/jev-seo, 543 stars), Analyzing Malicious PDF With Peepdf (mukul975/Anthropic-Cybersecurity-Skills, 34k stars), PDF Toolkit (borghei/Claude-Skills, 891 stars) and Edit PDF (SimplePDF/simplepdf-embed, 407 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains PDF Extraction Fallbacks 7d54a9?

HKUDS (a GitHub organization) maintains it in HKUDS/OpenSpace, which has 7,754 GitHub stars. The repository holds 199 skills in this directory. The repository was last updated on August 12, 2026.

Source: HKUDS/OpenSpace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.