pdf-read-file-fallback
하는 일
이 스킬은 내장 리더가 이미지나 바이너리 데이터로 반환하는 PDF의 예비 방법입니다. AI가 일반적으로 읽지 못하는 PDF 속 단어가 필요한 사람에게 맞습니다.
사용하는 경우
- ✓PDF를 읽을 때 텍스트 대신 이미지나 바이너리 데이터가 나올 때.
- ✓PDF가 스캔 문서이거나 복잡한 서식이 있는 경우.
- ✓읽을 수 있는 형태의 PDF 텍스트가 필요할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-read-file-fallback/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“AI가 제 PDF에서 바이너리 데이터만 가져옵니다. 명령줄 도구로 텍스트를 꺼내 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 먼저 일반 파일 읽기를 시도하고 결과가 쓸 만한지 확인합니다. 쓸 수 없으면 layout 옵션을 붙여 pdftotext를 실행해 텍스트를 얻습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PDF Text Extraction Fallback
When to Use
Use this pattern when read_file with filetype="pdf" returns binary image data instead of extractable text content. This commonly occurs with PDFs that contain scanned images or complex formatting.
Steps
1. Attempt Primary Extraction
First, try using read_file:
result = read_file(file_path="document.pdf", filetype="pdf")
Important: Use filetype (not file_type) - incorrect parameter naming will cause execution failures.
2. Detect Binary/Image Data
Check if the result contains unusable content:
# Indicators of binary/image data:
# - Contains null bytes: '\x00'
# - Very short or empty
# - Contains image markers (PNG/JPEG headers)
# - Unreadable character sequences
if not result or len(result) < 50 or '\x00' in str(result):
# Proceed to fallback
3. Use pdftotext via run_shell
Extract text using the pdftotext command-line tool:
shell_result = run_shell(command="pdftotext -layout document.pdf -")
text_content = shell_result.stdout
The - flag outputs to stdout for easy capture. The -layout flag preserves original formatting.
4. Handle pdftotext Unavailable
If pdftotext is not installed, try Python-based extraction:
result = execute_code_sandbox(code="""
import pdfplumber
text = ''
with pdfplumber.open('document.pdf') as pdf:
for page in pdf.pages:
extracted = page.extract_text()
if extracted:
text += extracted + '\\n'
print(text)
""")
Complete Example
file_path = "report.pdf"
# Primary attempt
result = read_file(file_path=file_path, filetype="pdf")
# Validate and fallback if needed
if not result or len(str(result)) < 100 or '\x00' in str(result):
# Fallback to pdftotext
shell_result = run_shell(command=f"pdftotext -layout {file_path} -")
text_content = shell_result.stdout
# If pdftotext fails, try Python extraction
if not text_content or len(text_content) < 50:
code_result = execute_code_sandbox(code=f"""
import pdfplumber
text = ''
with pdfplumber.open('{file_path}') as pdf:
for page in pdf.pages:
extracted = page.extract_text()
if extracted:
text += extracted + '\\n'
print(text)
""")
text_content = code_result
Notes
pdftotextis part of thepoppler-utilspackage on most Linux systems- For scanned/image-only PDFs, consider OCR tools (tesseract) instead
- Always validate parameter names against tool documentation (
filetypevsfile_type)
자주 묻는 질문
layout 옵션은 무엇을 하나요?
가능한 한 원래 페이지의 간격과 구조를 유지합니다.
pdftotext가 없으면 어떻게 하나요?
가이드는 pdfplumber 같은 Python 라이브러리를 대체 수단으로 제안합니다.
바이너리 출력은 어떻게 알아보나요?
가이드는 null 바이트, 아주 짧은 결과, 이미지 헤더 같은 신호를 언급합니다.
상세 정보
작성자의 원본 설명
Extract text from PDFs using pdftotext when read_file returns binary data
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12931
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
feishu-doc
394k에이전트가 문서 도구를 사용해 텍스트, 이미지, 표를 포함한 Feishu 클라우드 문서를 읽고, 만들고, 편집하도록 돕습니다.
feishu-drive
394k에이전트가 봇과 공유된 Feishu 클라우드 폴더의 파일을 찾아보고, 정리하고, 댓글을 달도록 돕습니다.
feishu-perm
394k에이전트가 요청을 충족하는 가장 작은 권한을 골라, Feishu 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.