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

reliable-pdf-extraction

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

यह स्किल AI एजेंट को pdftotext, pdfinfo या Python लाइब्रेरी से PDF पढ़ने का मार्गदर्शन देती है, जब अंतर्निहित रीडर खराब आउटपुट दे। यह उन लोगों के लिए है जो AI के ज़रिए PDF दस्तावेज़ों पर काम करते हैं।

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

  • ✓जब मानक PDF रीडर बाइनरी डेटा, एरर या खाली टेक्स्ट लौटाए।
  • ✓जब PDF का टेक्स्ट संरचित डेटा निकालने के लिए चाहिए।
  • ✓जब आप टेक्स्ट पढ़ने से पहले PDF का विवरण जाँचना चाहें।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reliable-pdf-extraction/SKILL.md

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

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

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

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

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

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

“मेरी जोड़ी हुई रिपोर्ट PDF पढ़िए और मुख्य बातें बताइए। सामान्य PDF रीडर एरर दे रहा है।”

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

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

एजेंट पहले सामान्य रीडर आज़माता है और नतीजा जाँचता है। अगर नतीजा गड़बड़ या खाली हो, तो वह शेल से pdftotext या pdfinfo चलाता है, या Python लाइब्रेरी इस्तेमाल करता है, और फिर निकाला गया टेक्स्ट पढ़ता है।

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

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

Reliable PDF Text Extraction

Problem

The read_file tool with filetype='pdf' often returns binary image data, errors, or unusable output when attempting to extract text from PDF documents. This makes it unreliable for structured data extraction tasks.

Solution

Use run_shell with command-line tools (pdftotext, pdfinfo) or execute_code_sandbox with Python libraries (PyMuPDF, pdfplumber) to extract PDF text content reliably.

Methods

Method 1: pdftotext (Recommended for simple extraction)

# Extract all text to stdout
pdftotext input.pdf -

# Or extract to file
pdftotext input.pdf output.txt
cat output.txt

Method 2: pdfinfo (For metadata)

pdfinfo input.pdf

Method 3: Python with PyMuPDF (fitz)

import fitz  # PyMuPDF

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

Method 4: Python with pdfplumber (Better for tables/structured data)

import pdfplumber

with pdfplumber.open("input.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        print(text)
        # For tables:
        # tables = page.extract_tables()

Workflow

  1. Attempt read_file with filetype='pdf' first (in case it works)

  2. Check output - If you receive:

    • Binary/garbage data
    • Error messages
    • Empty or truncated content
    • Image data instead of text
  3. Fall back to one of the extraction methods above:

    • Use pdftotext via run_shell for quick text extraction
    • Use pdfplumber via execute_code_sandbox for structured data/tables
    • Use PyMuPDF for complex layouts or when you need more control
  4. Process the extracted text for your task

Example Usage

# Via run_shell
result = run_shell(command="pdftotext document.pdf -")
pdf_text = result.stdout

# Via execute_code_sandbox
code = """
import pdfplumber
with pdfplumber.open("/path/to/document.pdf") as pdf:
    for page in pdf.pages:
        print(page.extract_text())
"""
result = execute_code_sandbox(code=code)
pdf_text = result.stdout

Tips

  • pdftotext is fastest and most reliable for plain text extraction
  • pdfplumber excels at extracting tables and preserving layout
  • PyMuPDF offers the most control for complex PDF structures
  • Always check if the PDF is scanned/image-based (may need OCR tools like tesseract)
  • Some PDFs have copy protection that may prevent text extraction
अक्सर पूछे जाने वाले सवाल

pdfinfo क्या दिखाता है?

यह पेज की संख्या और पेज का आकार जैसे विवरण दिखाता है, जो निकासी से पहले काम आते हैं।

क्या एजेंट हमेशा पहले सामान्य रीडर आज़माता है?

हाँ, स्किल कहती है कि पहले उसे आज़माएँ और आउटपुट गलत लगे तभी दूसरा तरीका लें।

कौन सी Python लाइब्रेरी बताई गई हैं?

स्किल सामान्य टेक्स्ट के लिए PyMuPDF और टेबल के लिए pdfplumber का नाम लेती है।

जानकारी

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

Use shell commands or Python libraries to extract PDF text when read_file PDF handler fails

repo: HKUDS/AgentPilot

लोकप्रियता

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

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

0

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

कमेंट

  • …

इस repository की और skills

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