pdf-text-extraction-9424c5
하는 일
이 스킬은 일반 리더가 실패할 때 pdftotext로 PDF에서 읽을 수 있는 텍스트를 추출하는 방법을 설명합니다. AI가 직접 읽지 못하는 PDF 문서를 다루는 사람에게 맞습니다.
사용하는 경우
- ✓PDF 읽기에서 깨지거나 바이너리 내용이 나올 때.
- ✓PDF에 스캔 이미지나 복잡한 바이너리 구조가 있는 경우.
- ✓PDF 텍스트를 파일로 저장하거나 나중 단계에 쓰고 싶을 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-text-extraction-9424c5/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 document.pdf의 텍스트를 읽어 주세요. 일반 리더는 깨진 결과를 주니 pdftotext로 추출해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 파일이 있는지 확인하고, pdftotext를 실행해 텍스트를 얻은 뒤, 바로 쓰거나 필요하면 임시 텍스트 파일로 저장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PDF Text Extraction via pdftotext
Problem
When using read_file on PDF documents, the function may return binary image data or garbled content instead of readable text. This occurs because PDFs can contain scanned images or complex binary structures that read_file cannot properly parse as text.
Solution
Use the pdftotext command-line utility via run_shell to extract clean text content from PDF files.
Steps
1. Verify PDF file exists
import os
pdf_path = "path/to/document.pdf"
if not os.path.exists(pdf_path):
raise FileNotFoundError(f"PDF not found: {pdf_path}")
2. Extract text using pdftotext
from tools import run_shell
# Extract text to stdout
result = run_shell(command=f"pdftotext '{pdf_path}' -", timeout=60)
pdf_text = result.stdout
# Alternative: extract to a temporary file
temp_txt = "/tmp/extracted.txt"
run_shell(command=f"pdftotext '{pdf_path}' '{temp_txt}'", timeout=60)
with open(temp_txt, 'r') as f:
pdf_text = f.read()
3. Handle parameter naming carefully
When calling read_file, be aware of the parameter name:
- Use
filetype="pdf"(notfile_type) - Some tool implementations may use different parameter names
# Correct parameter usage
content = read_file(file_path="doc.pdf", filetype="pdf")
# If this returns binary/garbled data, fall back to pdftotext
Common pdftotext Options
| Option | Description |
|---|---|
- |
Output to stdout |
-layout |
Maintain original layout |
-f <n> |
Start from page n |
-l <n> |
End at page n |
-q |
Quiet mode |
Example with options:
result = run_shell(command=f"pdftotext -layout -q '{pdf_path}' -", timeout=60)
Error Handling
from tools import run_shell
def extract_pdf_text(pdf_path):
"""Extract text from PDF using pdftotext with error handling."""
import os
if not os.path.exists(pdf_path):
raise FileNotFoundError(f"PDF not found: {pdf_path}")
result = run_shell(command=f"pdftotext '{pdf_path}' -", timeout=60)
if result.returncode != 0:
raise RuntimeError(f"pdftotext failed: {result.stderr}")
return result.stdout.strip()
When to Use This Pattern
read_filereturns binary data, garbled text, or image content for a PDF- You need searchable/processable text from PDF documents
- The PDF contains text (not just scanned images - for those, consider OCR tools)
Prerequisites
pdftotextmust be installed (part ofpoppler-utilson Debian/Ubuntu,poppleron macOS via Homebrew)- Verify availability:
run_shell(command="which pdftotext")
자주 묻는 질문
파일이 있는지 먼저 확인하는 이유는 무엇인가요?
PDF 경로가 틀리면 가이드는 분명한 오류와 함께 멈춥니다.
read_file 매개변수 팁은 무엇인가요?
읽기 도구를 호출할 때 file_type 대신 filetype을 쓰라고 가이드가 안내합니다.
출력은 어디로 갈 수 있나요?
화면에 출력하거나 텍스트 파일에 쓸 수 있습니다.
상세 정보
작성자의 원본 설명
Extract text from PDF files using pdftotext when read_file returns binary data
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12932
- 라이선스
- 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 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.