मुख्य सामग्री पर जाएँ
Skillpedia
PDF, Word और स्लाइड7.8k · #12917

pdf-extract-shell-first

यह क्या करती है

यह स्किल PDF से टेक्स्ट निकालने के टूल्स का क्रम बताती है, जिसमें शेल टूल सबसे पहले है क्योंकि वह सबसे भरोसेमंद है। यह उन लोगों के लिए है जिन्हें PDF का टेक्स्ट चाहिए और कम विफल प्रयास चाहिए।

कब इस्तेमाल करें

  • ✓जब PDF मेरे कंप्यूटर पर हो और मुझे उसका टेक्स्ट जल्दी से जल्दी चाहिए।
  • ✓जब PDF किसी वेब पते पर हो और पढ़ने से पहले डाउनलोड करनी हो।
  • ✓जब मुझे सबसे भरोसेमंद निकासी चाहिए और सारे फ़ॉलबैक टूल उपलब्ध रखने हैं।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-e27e0c/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-e27e0c/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“इस PDF का टेक्स्ट निकालिए, चाहे वह स्थानीय हो या वेब लिंक से। पहले शेल टूल इस्तेमाल कीजिए, और ज़रूरत हो तो फिर Python टूल।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

अगर PDF ऑनलाइन है, तो AI उसे ब्राउज़र जैसे अनुरोध से डाउनलोड करता है। फिर वह सरल रीड आज़माता है, शेल से pdftotext चलाता है, और अंतिम विकल्प के रूप में Python इस्तेमाल करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

PDF Extract with Shell-First Tool Cascade

This skill provides an optimized workflow for extracting text content from PDF documents (local files or downloaded URLs) using a prioritized tool cascade that favors shell-based extraction before falling back to Python libraries.

Why Shell-First?

Analysis of execution patterns shows:

  • read_file on PDFs sometimes returns binary/image data instead of text
  • run_shell with pdftotext has higher success rate and fewer sandbox errors
  • execute_code_sandbox can fail with "unknown error" in constrained environments
  • Shell tools are more reliable for PDF text extraction when available

Entry Point: Determine Your Starting Point

Before beginning, identify your scenario:

Scenario Start Here Skip
PDF already on local disk Step 1 (Try read_file) Shell download steps
PDF at a web URL Shell download, then Step 1 None
Need maximum reliability Full cascade (all 3 tools) None

Complete Workflow

Step 0: Download PDF (URL Only)

If your PDF is at a web URL, download it first using browser user-agent:

curl -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -o target.pdf "URL_HERE"

Key flags:

  • -L: Follow redirects
  • -A: Set user-agent header to mimic a real browser
  • -o: Specify output filename

If you already have the PDF locally, skip to Step 1.

Step 1: Try read_file (Primary Attempt)

First, attempt to extract text using the read_file tool:

read_file(filetype="pdf", file_path="target.pdf")

Evaluate the response:

Response Type Interpretation Next Action
Clean readable text Success Proceed to content analysis
Binary data / PNG image / garbled read_file returned raw data Go to Step 2 immediately
Error / timeout Tool failure Go to Step 2 immediately

Critical: If read_file returns binary image data or garbled content, do not retry read_file. Immediately proceed to Step 2.

Step 2: Use run_shell with pdftotext (Preferred Fallback)

When read_file fails or returns binary data, use run_shell with pdftotext:

run_shell(command="pdftotext target.pdf output.txt")

Then read the extracted text:

read_file(filetype="txt", file_path="output.txt")

If pdftotext is not found, install it first:

run_shell(command="apt-get update && apt-get install -y poppler-utils")
# Or for macOS:
run_shell(command="brew install poppler")

Then retry:

run_shell(command="pdftotext target.pdf output.txt")

Verify extraction quality:

  • Check that output.txt exists and has content
  • Sample the text to ensure it's readable (not garbled)
  • If extraction looks corrupted, proceed to Step 3

Step 3: Use execute_code_sandbox with PyMuPDF (Last Resort)

If pdftotext is unavailable or produces poor results, use Python's PyMuPDF via execute_code_sandbox:

import fitz  # PyMuPDF

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

with open("output.txt", "w") as f:
    f.write(text)
print(f"Extracted {len(text)} characters from {len(doc)} pages")

Execute via:

execute_code_sandbox(code="<python code above>")

Then read the result:

read_file(filetype="txt", file_path="output.txt")

Note: execute_code_sandbox may fail with "unknown error" in some environments. If this occurs, document the failure and proceed to Step 4.

Step 4: Graceful Degradation to Domain Knowledge

If all extraction methods fail:

  1. Document the specific failure mode for each tool attempted
  2. Extract any partial content that was successfully retrieved
  3. Supplement missing content from established domain knowledge
  4. Clearly mark which portions are from source vs. generated from knowledge
  5. Provide citations for any claimed requirements or specifications

Example degradation documentation:

EXTRACTION FAILURE REPORT:
- Source: [URL or file path]
- read_file: Returned binary/image data (no text extraction)
- run_shell/pdftotext: [Tool not available / produced garbled output / succeeded]
- execute_code_sandbox/PyMuPDF: [Failed with unknown error / succeeded]

NOTE: Content below combines partial extraction with established domain 
knowledge for [topic]. Verify against official sources when available.
``
अक्सर पूछे जाने वाले सवाल

शेल टूल पहले क्यों?

गाइड के अनुसार pdftotext की सफलता दर ज़्यादा है और सैंडबॉक्स एरर कम आती हैं।

वेब PDF कैसे डाउनलोड होती है?

curl से, ब्राउज़र जैसे हेडर के साथ और रीडायरेक्ट का पालन करते हुए।

अगर सारे टूल विफल हों तो?

गाइड का क्रम तीनों टूल्स से गुज़रता है, इसलिए हार मानने से पहले आखिरी Python विकल्प भी आज़माया जाता है।

जानकारी

लेखक का मूल विवरण

PDF text extraction with tool cascade prioritizing shell pdftotext before Python fallback

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#12917
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills