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

robust-pdf-read

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

यह स्किल AI एजेंट को pdftotext टूल से PDF का पढ़ने योग्य टेक्स्ट निकालना दिखाती है। यह उन लोगों के लिए है जिनकी PDF रीडिंग अपठनीय अक्षरों के रूप में वापस आती है।

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

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

Skill का लिंक

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

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

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

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

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

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

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

“मेरी लीज़ PDF पढ़िए और मुझे उसका टेक्स्ट दीजिए। फ़ाइल रीडर सिर्फ़ गड़बड़ अक्षर दिखा रहा है।”

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

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

एजेंट सामान्य रीडर के आउटपुट में बाइनरी या गड़बड़ सामग्री जाँचता है। अगर ऐसा मिले, तो वह layout विकल्पों और बिना page break अक्षरों के साथ pdftotext चलाता है, और पढ़ने के लिए टेक्स्ट standard output पर भेजता है।

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

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

Robust PDF Text Extraction

Problem

Standard file reading tools (e.g., read_file) often fail to extract text from PDF documents. Instead of returning parsed text, they may return:

  • Raw binary data
  • Base64 encoded images
  • Garbled characters or null bytes

This occurs because PDFs are complex binary formats, not plain text files. Attempts to parse them using general-purpose Python libraries (like PyMuPDF) in sandboxed environments may also fail due to missing dependencies or environment restrictions.

Solution

Use the pdftotext command-line utility (part of poppler-utils) via run_shell. This tool is commonly pre-installed in Linux environments and reliably extracts text content from PDFs.

Procedure

1. Detect Extraction Failure

When attempting to read a PDF:

  • Check the content returned by read_file.
  • If the content contains null bytes (\x00), appears as base64, or is clearly binary/garbled, assume standard reading has failed.

2. Execute pdftotext

Run the following shell command using run_shell:

pdftotext -layout -nopgbrk <file_path> -
  • -layout: Maintains the physical layout of the text (optional but recommended).
  • -nopgbrk: Prevents inserting form feed characters between pages.
  • -: Outputs content to stdout instead of creating a new file.

3. Parse Output

Capture the stdout from the shell command. This string is the extracted text.

Example Usage

Scenario: You need to read document.pdf.

Step 1: Attempt standard read

content = read_file("document.pdf")
if "\x00" in content or not content.strip():
    # Fallback needed
    pass

Step 2: Fallback to shell

result = run_shell("pdftotext -layout -nopgbrk document.pdf -")
text = result.stdout

Prerequisites

  • The environment must have pdftotext installed (usually via poppler-utils).
  • If pdftotext is not found, attempt to install it (apt-get install poppler-utils) if permissions allow, or notify the user.

Benefits

  • Reliability: Bypasses Python library dependency issues in sandboxes.
  • Speed: Command-line tools are often faster than loading heavy Python libraries.
  • Compatibility: Works consistently across most Linux-based agent environments.
अक्सर पूछे जाने वाले सवाल

एजेंट विफल रीड कैसे पहचानता है?

वह null bytes, base64 जैसा दिखने वाला डेटा या साफ़ तौर पर गड़बड़ टेक्स्ट खोजता है।

pdftotext के विकल्प क्या करते हैं?

layout विकल्प पेज का लेआउट बनाए रखता है, और nopgbrk विकल्प page break अक्षर हटाता है।

क्या इसके लिए कोई खास इंस्टॉल चाहिए?

स्किल कहती है कि pdftotext poppler-utils का हिस्सा है, जो Linux सिस्टम पर अक्सर पहले से इंस्टॉल होता है।

जानकारी

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

Reliably extract text from PDFs using pdftotext when standard file reading fails.

repo: HKUDS/AgentPilot

लोकप्रियता

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

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

0

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

कमेंट

  • …

इस repository की और skills

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