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

pdf-text-extraction

하는 일

이 스킬은 내장 핸들러를 믿을 수 없을 때 PDF 텍스트를 추출하는 여러 방법을 나열합니다. 분석이나 요약에 읽을 수 있는 PDF 내용이 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓PDF를 읽을 때 이미지 데이터, 오류 또는 불완전한 내용이 나올 때.
  • ✓PDF의 페이지 수나 메타데이터가 필요한 경우.
  • ✓간단한 방법으로는 부족해서 PDF의 표 데이터가 필요할 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-text-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/pdf-text-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 리더가 제 보고서에서 실패합니다. 텍스트를 꺼내고 몇 쪽인지도 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 텍스트에는 pdftotext, 메타데이터에는 pdfinfo, Python 방법에는 PyMuPDF, 표에는 pdfplumber를 고르고, 선택한 명령을 셸에서 실행합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

PDF Text Extraction (Fallback Method)

When to Use This Skill

Use this skill when read_file with filetype='pdf':

  • Returns binary image data instead of text
  • Produces errors or incomplete content
  • Fails to extract structured data reliably

The built-in PDF handler is unreliable for structured text extraction. Shell-based tools provide more robust alternatives.

Available Methods

Method 1: pdftotext (Recommended)

# Extract text from PDF to stdout
pdftotext /path/to/file.pdf -

# Extract text to a file
pdftotext /path/to/file.pdf output.txt

# Preserve layout (maintains spacing/structure)
pdftotext -layout /path/to/file.pdf output.txt

Usage in agent:

run_shell command="pdftotext -layout /path/to/document.pdf -"

Method 2: pdfinfo (Metadata)

# Get PDF metadata (pages, author, creation date, etc.)
pdfinfo /path/to/file.pdf

Usage in agent:

run_shell command="pdfinfo /path/to/document.pdf"

Method 3: Python with PyMuPDF (fitz)

import fitz  # PyMuPDF

doc = fitz.open("/path/to/file.pdf")
text = ""
for page in doc:
    text += page.get_text()
doc.close()
print(text)

Usage in agent:

run_shell command="python3 -c \"import fitz; doc=fitz.open('file.pdf'); print(''.join(p.get_text() for p in doc))\""

Method 4: Python with pdfplumber (Tables)

import pdfplumber

with pdfplumber.open("/path/to/file.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        tables = page.extract_tables()  # For tabular data

Usage in agent:

run_shell command="python3 -c \"import pdfplumber; pdf=pdfplumber.open('file.pdf'); print(''.join(p.extract_text() or '' for p in pdf.pages))\""

Workflow

  1. Try pdftotext first - Fastest and most reliable for plain text

    run_shell command="pdftotext -layout /path/to/file.pdf -"
    
  2. If pdftotext unavailable, check for Python libraries

    run_shell command="python3 -c \"import fitz; print('PyMuPDF available')\""
    
  3. For table/structured data, use pdfplumber

    run_shell command="python3 -c \"import pdfplumber; ...\""
    
  4. Verify extraction succeeded - Check output contains readable text, not binary data

Installation Notes

If tools are not available:

# Ubuntu/Debian
apt-get install poppler-utils  # pdftotext, pdfinfo

# Install Python libraries
pip install pymupdf pdfplumber

Anti-Patterns to Avoid

  • Do NOT rely solely on read_file with filetype='pdf' for critical text extraction
  • Do NOT assume PDF text is in any particular order - verify extracted content
  • Do NOT use image-based extraction unless the PDF is scanned (use OCR instead)

Example: Complete Extraction Pattern

# Step 1: Try pdftotext
RESULT=$(pdftotext -layout /path/to/form.pdf - 2>/dev/null)

# Step 2: Verify we got text, not error
if [ -z "$RESULT" ]; then
    # Fallback to Python
    RESULT=$(python3 -c "import fitz; doc=fitz.open('/path/to/form.pdf'); print(''.join(p.get_text() for p in doc))")
fi

# Step 3: Use extracted text
echo "$RESULT"
자주 묻는 질문

pdfinfo는 무엇을 보여 주나요?

페이지 수, 제목, 작성자, 생성 날짜 같은 메타데이터를 보여 줍니다.

pdfplumber는 언제 유용한가요?

가이드는 PDF에서 표를 추출할 때 이 라이브러리를 추천합니다.

내장 핸들러는 항상 믿을 수 없나요?

가이드는 구조화된 텍스트 추출에는 믿기 어렵다고 말하고, 셸 도구를 우선합니다.

상세 정보

작성자의 원본 설명

Extract text from PDFs using shell tools when read_file fails

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12935
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬