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 पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
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
Attempt
read_filewithfiletype='pdf'first (in case it works)Check output - If you receive:
- Binary/garbage data
- Error messages
- Empty or truncated content
- Image data instead of text
Fall back to one of the extraction methods above:
- Use
pdftotextviarun_shellfor quick text extraction - Use
pdfplumberviaexecute_code_sandboxfor structured data/tables - Use
PyMuPDFfor complex layouts or when you need more control
- Use
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
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
feishu-doc
394kयह आपके एजेंट को document टूल से Feishu क्लाउड दस्तावेज़ पढ़ने, बनाने और बदलने में मदद करती है, जिसमें टेक्स्ट, इमेज और टेबल शामिल हैं।
feishu-drive
394kयह आपके एजेंट को बॉट के साथ साझा किए गए Feishu क्लाउड फ़ोल्डर में फ़ाइलें देखने, व्यवस्थित करने और उन पर टिप्पणी करने देती है।
feishu-perm
394kयह आपके एजेंट को Feishu फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।