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

pdf-extract-progressive-tools

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

यह स्किल PDF टेक्स्ट निकालने के लिए एक चरण-दर-चरण क्रम बताती है, जब पहला तरीका पढ़ने योग्य नहीं देता। यह उन लोगों के लिए है जिनका AI PDF से बाइनरी या गड़बड़ आउटपुट पाता है।

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

  • ✓जब PDF पढ़ने पर टेक्स्ट की जगह बाइनरी या इमेज डेटा आए।
  • ✓जब मुझे सारांश या विश्लेषण के लिए भरोसेमंद PDF टेक्स्ट चाहिए।
  • ✓जब फ़ाइल जटिल PDF हो, जिसे सरल टूल नहीं पढ़ सकते।

Skill का लिंक

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

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

“मेरी PDF से AI को हर बार गड़बड़ टेक्स्ट मिल रहा है। पहले आसान तरीका आज़माइए, फिर बाकी टूल क्रम से तब तक, जब तक साफ़ टेक्स्ट न मिले।”

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

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

AI सरल फ़ाइल रीड आज़माता है, विफल होने पर शेल से pdftotext चलाता है, और अंत में कोड सैंडबॉक्स में PyMuPDF वाली Python स्क्रिप्ट इस्तेमाल करता है, और अंत में टेक्स्ट की गुणवत्ता जाँचता है।

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

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

PDF Text Extraction with Progressive Tool Fallback

This skill provides a robust workflow for extracting text from PDF documents using a sequenced approach with agent tools, with explicit fallback mechanisms based on observed tool behavior.

Critical Insight from Execution Data

read_file often returns binary/image data for PDFs, not extracted text. When this occurs, immediately escalate to run_shell with pdftotext before attempting Python-based extraction.

Entry Point: Determine Your Starting Point

Before beginning, identify your scenario:

Scenario Start Here Skip
PDF already on local disk Step 1 (read_file attempt) Download steps
PDF at a web URL Download first, then Step 1 None
PDF content already extracted Step 4 (Quality verification) Steps 1-3

Overview

PDF extraction failures cascade when tool sequencing is unclear. This workflow ensures maximum success rate through explicit tool progression:

  1. read_file - Quick attempt, but may return binary data
  2. run_shell + pdftotext - Reliable extraction when read_file fails
  3. execute_code_sandbox + PyMuPDF - Final fallback for complex PDFs

Step-by-Step Instructions

Step 1: Attempt read_file First

Always try the simplest approach first:

Tool: read_file
Path: document.pdf

Expected outcome: Extracted text content

Critical check: Examine the returned content:

  • ✅ Text visible: Proceed to Step 4 (Quality verification)
  • ⚠️ Binary/image data detected: Immediately proceed to Step 2
  • ❌ File not found: Verify path or download first

Binary data indicators:

  • Content starts with %PDF- header without text extraction
  • Content appears as garbled characters or base64
  • Content contains PNG/JPEG markers within PDF wrapper
  • File size seems reasonable but no readable text

Step 2: Escalate to run_shell with pdftotext

When read_file returns binary data, do NOT attempt execute_code_sandbox yet. Use run_shell immediately:

Tool: run_shell
Command: pdftotext document.pdf document.txt

If pdftotext is not available:

Tool: run_shell
Command: apt-get update && apt-get install -y poppler-utils && pdftotext document.pdf document.txt

Then read the extracted text:

Tool: read_file
Path: document.txt

Expected outcome: Clean text extraction

If this fails:

  • Check if file is password-protected
  • Check if file is corrupted (run file document.pdf)
  • Proceed to Step 3

Step 3: Final Fallback to execute_code_sandbox with PyMuPDF

Only attempt this if Steps 1-2 fail:

Tool: execute_code_sandbox
Language: python
Code: |
  import fitz  # PyMuPDF
  
  try:
      doc = fitz.open("document.pdf")
      text = ""
      for page in doc:
          text += page.get_text()
      doc.close()
      
      with open("document_pymupdf.txt", "w") as f:
          f.write(text)
      
      print("SUCCESS: Extracted {} characters".format(len(text)))
  except Exception as e:
      print(f"FAILED: {e}")

Then read the result:

Tool: read_file
Path: document_pymupdf.txt

Step 4: Quality Verification

Regardless of which method succeeded, verify extraction quality:

  1. Check text length: Should be proportional to PDF pages (~500-2000 chars per page)
  2. Check readability: Text should form coherent sentences
  3. Check for truncation: Look for cut-off words or missing sections
  4. Compare methods: If multiple methods worked, compare outputs

If quality is poor:

  • Try alternative extraction tools (pdfplumber, camelot-py for tables)
  • Consider OCR for scanned documents
  • Document limitations clearly

Step 5: 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 note:

NOTE: Source document [path/URL] was inaccessible due to [specific tool failures].
Content below combines partial extraction with established domain knowledge 
for [topic]. All claims verified against [alternative sources] where possible.

Tool Failure Log:
- read_file: Returned binary data (no text extraction)
- run_shell/pdftotext: Comman
अक्सर पूछे जाने वाले सवाल

सरल रीड से क्यों शुरू करें?

गाइड के अनुसार यह सबसे तेज़ प्रयास है, हालाँकि कभी-कभी यह बाइनरी डेटा लौटाता है।

pdftotext को Python से पहले क्यों आज़माएँ?

गाइड ने सीमित वातावरण में शेल टूल्स को ज़्यादा भरोसेमंद पाया।

क्या टेक्स्ट की गुणवत्ता जाँची जाती है?

हाँ, गाइड में निकाले गए टेक्स्ट की गुणवत्ता जाँचने का एक चरण है।

जानकारी

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

Progressive tool-chain PDF extraction with explicit read_file, run_shell, and execute_code_sandbox sequencing

repo: HKUDS/AgentPilot

लोकप्रियता

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

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

0

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

कमेंट

  • …

इस repository की और skills

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