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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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
Attempt
read_filewithfiletype='pdf'first (in case it works)Check output - If you receive:
- Binary/garbage data
- Error messages
- Empty or truncated content
- Image data instead of text
Fall back to one of the extraction methods above:
- Use
pdftotextviarun_shellfor quick text extraction - Use
pdfplumberviaexecute_code_sandboxfor structured data/tables - Use
PyMuPDFfor complex layouts or when you need more control
- Use
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.
댓글
- …
이 저장소의 다른 스킬
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 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.