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

robust-pdf-read

하는 일

이 스킬은 pdftotext 도구로 PDF에서 읽을 수 있는 텍스트를 꺼내는 방법을 AI 에이전트에게 보여 줍니다. PDF 읽기 결과가 알아볼 수 없는 문자로만 나오는 사람에게 맞습니다.

사용하는 경우

  • ✓파일 리더가 PDF에 대해 바이너리, base64 이미지 데이터 또는 깨진 문자를 반환할 때.
  • ✓작업에 쓰려고 PDF의 단어를 일반 텍스트로 얻어야 할 때.
  • ✓PDF 텍스트의 레이아웃을 원본에 가깝게 유지하고 싶은 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/robust-pdf-read/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/robust-pdf-read/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분.

작동 방식

에이전트는 일반 리더 출력에 바이너리나 깨진 내용이 있는지 확인합니다. 있으면 레이아웃 옵션과 페이지 나눔 문자를 없애는 옵션을 붙여 pdftotext를 실행하고, 텍스트를 표준 출력으로 보내 읽습니다.

기술 내용 (원본 SKILL.md)

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

Robust PDF Text Extraction

Problem

Standard file reading tools (e.g., read_file) often fail to extract text from PDF documents. Instead of returning parsed text, they may return:

  • Raw binary data
  • Base64 encoded images
  • Garbled characters or null bytes

This occurs because PDFs are complex binary formats, not plain text files. Attempts to parse them using general-purpose Python libraries (like PyMuPDF) in sandboxed environments may also fail due to missing dependencies or environment restrictions.

Solution

Use the pdftotext command-line utility (part of poppler-utils) via run_shell. This tool is commonly pre-installed in Linux environments and reliably extracts text content from PDFs.

Procedure

1. Detect Extraction Failure

When attempting to read a PDF:

  • Check the content returned by read_file.
  • If the content contains null bytes (\x00), appears as base64, or is clearly binary/garbled, assume standard reading has failed.

2. Execute pdftotext

Run the following shell command using run_shell:

pdftotext -layout -nopgbrk <file_path> -
  • -layout: Maintains the physical layout of the text (optional but recommended).
  • -nopgbrk: Prevents inserting form feed characters between pages.
  • -: Outputs content to stdout instead of creating a new file.

3. Parse Output

Capture the stdout from the shell command. This string is the extracted text.

Example Usage

Scenario: You need to read document.pdf.

Step 1: Attempt standard read

content = read_file("document.pdf")
if "\x00" in content or not content.strip():
    # Fallback needed
    pass

Step 2: Fallback to shell

result = run_shell("pdftotext -layout -nopgbrk document.pdf -")
text = result.stdout

Prerequisites

  • The environment must have pdftotext installed (usually via poppler-utils).
  • If pdftotext is not found, attempt to install it (apt-get install poppler-utils) if permissions allow, or notify the user.

Benefits

  • Reliability: Bypasses Python library dependency issues in sandboxes.
  • Speed: Command-line tools are often faster than loading heavy Python libraries.
  • Compatibility: Works consistently across most Linux-based agent environments.
자주 묻는 질문

실패한 읽기는 어떻게 알아보나요?

널 바이트, base64처럼 보이는 데이터, 분명히 깨진 텍스트를 찾습니다.

pdftotext 옵션은 무엇을 하나요?

layout 옵션은 레이아웃을 유지하고, nopgbrk 옵션은 페이지 나눔 문자를 없앱니다.

특별한 설치가 필요한가요?

pdftotext는 poppler-utils의 일부이며, Linux 시스템에는 보통 이미 설치되어 있다고 스킬이 말합니다.

상세 정보

작성자의 원본 설명

Reliably extract text from PDFs using pdftotext when standard file reading fails.

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬