본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12968

reliable-pdf-extraction

하는 일

이 스킬은 내장 리더가 나쁜 출력을 줄 때 pdftotext, pdfinfo 또는 Python 라이브러리로 PDF를 읽도록 AI 에이전트를 안내합니다. AI를 통해 PDF 문서를 다루는 사람에게 맞습니다.

사용하는 경우

  • ✓표준 PDF 리더가 바이너리 데이터, 오류 또는 빈 텍스트를 반환할 때.
  • ✓구조화된 데이터 추출에 쓸 PDF의 텍스트가 필요할 때.
  • ✓텍스트를 읽기 전에 PDF의 세부 정보를 확인하고 싶은 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reliable-pdf-extraction/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제가 첨부한 보고서 PDF를 읽고 주요 내용을 알려 주세요. 일반 PDF 리더가 오류를 냅니다.”

매주 새 스킬 5개. 읽는 데 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
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬