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

pdf-text-extraction-fallback

하는 일

이 스킬은 내장 파일 리더가 실패할 때 pdftotext로 PDF 텍스트를 추출하는 방법을 설명합니다. 이미지나 복잡한 서식이 있는 PDF를 다루는 사람에게 맞습니다.

사용하는 경우

  • ✓PDF를 읽을 때 바이너리나 이미지 데이터가 나올 때.
  • ✓PDF에 내장된 이미지나 복잡한 서식이 있는 경우.
  • ✓작업에 쓸 읽을 수 있는 PDF 텍스트가 필요할 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-text-extraction-fallback/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-fallback/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에 대해 바이너리 데이터를 줍니다. 호출 설정을 확인하고 pdftotext로 텍스트를 추출해 주세요.”

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

작동 방식

AI는 읽기 호출에 올바른 매개변수 이름이 쓰였는지 확인하고, 바이너리 출력을 감지한 뒤, pdftotext를 실행해 표준 출력에 텍스트를 출력합니다.

기술 내용 (원본 SKILL.md)

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

PDF Text Extraction Fallback

When to Use This Skill

Use this skill when read_file with filetype="pdf" returns binary/image data instead of readable text content. This is a common issue with PDF files that contain embedded images or complex formatting.

Steps

1. Validate Parameters First

Before attempting extraction, ensure you're using the correct parameter name:

  • Use filetype (not file_type) for the read_file function
  • Incorrect parameter names can cause silent failures
# Correct
read_file(filetype="pdf", file_path="document.pdf")

# Incorrect - may fail silently
read_file(file_type="pdf", file_path="document.pdf")

2. Detect Binary Data Issue

After calling read_file, check if the result contains:

  • Garbled/binary characters
  • Image data representations (e.g., b'...' byte strings with non-text content)
  • Unreadable or corrupted-looking content

If yes, proceed with the pdftotext workaround.

3. Extract Text via pdftotext

Use run_shell to call pdftotext, which extracts text directly from PDF files:

# Extract text to stdout
result = run_shell(command="pdftotext /path/to/document.pdf -")
text_content = result.stdout

The - flag tells pdftotext to output to stdout instead of creating a file.

4. Handle Output and Errors

result = run_shell(command="pdftotext /path/to/document.pdf -")

if result.stderr:
    # Check for errors like "pdftotext not found"
    # May need to install poppler-utils
    pass

text_content = result.stdout
# text_content now contains the extracted text

Example Workflow

# Step 1: Try normal read with correct parameters
content = read_file(filetype="pdf", file_path="reference.pdf")

# Step 2: Check if content is readable
if not content or looks_like_binary(content):
    # Step 3: Fall back to pdftotext
    result = run_shell(command="pdftotext reference.pdf -")
    text_content = result.stdout
    
    # Step 4: Verify extraction succeeded
    if result.stderr:
        # Handle error (e.g., install pdftotext)
        pass

Installation Notes

pdftotext is part of the poppler-utils package:

  • Debian/Ubuntu: apt-get install poppler-utils
  • macOS: brew install poppler
  • Many Linux environments: Pre-installed

Alternative: Output to File

If stdout approach has issues, output to a temporary file:

run_shell(command="pdftotext /path/to/document.pdf /tmp/output.txt")
text_content = read_file(filetype="txt", file_path="/tmp/output.txt")

Best Practices

  1. Always validate the filetype parameter spelling before troubleshooting
  2. Check both stdout and stderr from pdftotext
  3. For multi-page PDFs, pdftotext preserves page breaks with form feeds
  4. This method works better for text-based PDFs than image-scanned PDFs
자주 묻는 질문

매개변수 이름이 왜 중요한가요?

가이드는 잘못된 매개변수 이름이 소리 없는 실패를 일으킬 수 있다고 말합니다.

바이너리 출력은 어떻게 알아보나요?

결과에서 바이너리 문자나 이미지 데이터 표시를 찾습니다.

명령의 하이픈은 무엇을 하나요?

pdftotext에 텍스트를 파일이 아니라 화면으로 출력하라고 알려 줍니다.

상세 정보

작성자의 원본 설명

Extract text from PDFs using pdftotext when read_file returns binary data

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬