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

local-pdf-extraction

하는 일

이 스킬은 셸에서 pdftotext나 PyMuPDF 라이브러리로 로컬 PDF 파일의 텍스트를 추출하는 방법을 설명합니다. AI가 직접 읽지 못하는 PDF의 내용이 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓컴퓨터의 PDF 파일이 깨진 문자나 바이너리 데이터로 나올 때.
  • ✓폴더의 여러 PDF 내용을 요약하거나 분석해야 할 때.
  • ✓나중에 쓸 수 있도록 PDF 텍스트를 일반 텍스트 파일로 저장하고 싶은 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/local-pdf-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/local-pdf-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는 PDF 파일 목록을 만들고, pdftotext 또는 짧은 PyMuPDF 스크립트로 각 파일을 텍스트로 바꾼 뒤, 저장된 텍스트 파일을 읽습니다.

기술 내용 (원본 SKILL.md)

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

Local PDF Extraction Workflow

Use this skill when you need to extract text from PDF files that exist locally on the filesystem, and read_file returns binary data instead of readable text.

When to Use

  • PDF files exist in the local workspace or known directories
  • read_file on PDFs returns binary/garbled data instead of text
  • You need to process PDF content for analysis, summarization, or data extraction

Step-by-Step Instructions

Step 1: Locate PDF Files

First, list directory contents to find all PDF files:

ls -la *.pdf
# or for recursive search
find . -name "*.pdf" -type f

Step 2: Extract PDFs to Text

Choose one of these methods based on available tools:

Method A: Using pdftotext (poppler-utils)

# Extract single PDF
pdftotext input.pdf output.txt

# Batch extract all PDFs in directory
for pdf in *.pdf; do
    pdftotext "$pdf" "${pdf%.pdf}.txt"
done

Method B: Using PyMuPDF (fitz) via Python

python3 << 'EOF'
import fitz  # PyMuPDF
import glob
import os

for pdf_path in glob.glob("*.pdf"):
    doc = fitz.open(pdf_path)
    text = ""
    for page in doc:
        text += page.get_text()
    
    txt_path = pdf_path.replace(".pdf", ".txt")
    with open(txt_path, "w", encoding="utf-8") as f:
        f.write(text)
    print(f"Extracted: {pdf_path} -> {txt_path}")
EOF

Step 3: Read Extracted Text Files

Once extracted, use read_file to read the .txt files:

# Now you can read the text files normally
content = read_file(filetype="txt", file_path="document.txt")

Step 4: Process Content

Proceed with your analysis, summarization, or data extraction on the text content.

Complete Workflow Example

# Step 1: Find PDFs
ls -la *.pdf

# Step 2: Extract all PDFs to text
for pdf in *.pdf; do
    pdftotext "$pdf" "${pdf%.pdf}.txt"
done

# Step 3: Verify extraction
ls -la *.txt

Or as a Python script via run_shell:

python3 << 'SCRIPT'
import fitz, glob
for pdf in glob.glob("*.pdf"):
    doc = fitz.open(pdf)
    text = "".join(page.get_text() for page in doc)
    with open(pdf.replace(".pdf", ".txt"), "w") as f:
        f.write(text)
    print(f"Done: {pdf}")
SCRIPT

Troubleshooting

  • pdftotext not found: Install with apt-get install poppler-utils or use PyMuPDF method
  • Empty text output: PDF may be image-based; consider OCR tools like pdftoppm + tesseract
  • Encoding issues: Ensure output files use UTF-8 encoding

Key Takeaways

  1. Never use read_file directly on PDFs for text extraction
  2. Always list directory first to confirm PDF locations
  3. Use run_shell with pdftotext or PyMuPDF for reliable extraction
  4. Batch process when multiple PDFs exist
  5. Read the resulting .txt files for further processing
자주 묻는 질문

pdftotext는 무엇인가요?

PDF 파일을 일반 텍스트로 바꾸는 명령줄 도구입니다.

폴더 전체를 처리할 수 있나요?

네, 가이드에는 폴더의 모든 PDF를 변환하는 반복문이 있습니다.

어떤 방법을 골라야 하나요?

컴퓨터에서 쓸 수 있는 방법, 즉 pdftotext나 PyMuPDF 중 하나를 쓰라고 가이드가 말합니다.

상세 정보

작성자의 원본 설명

Extract text from local PDFs using pdftotext or PyMuPDF via run_shell

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬