Zum Inhalt springen
Skillpedia
PDF, Word & Folien7.8k · #12977

robust-pdf-read

Was er macht

Dieser Skill zeigt dem KI-Agenten, wie er mit dem Werkzeug pdftotext lesbaren Text aus einer PDF holt. Er richtet sich an Menschen, deren PDF-Lesen unlesbare Zeichen zurückgibt.

Wann du ihn nutzt

  • ✓Wenn der Dateileser rohe Binärdaten, Base64-Bilddaten oder verzerrte Zeichen für eine PDF zurückgibt.
  • ✓Wenn du die Wörter einer PDF als Klartext zum Arbeiten brauchst.
  • ✓Wenn du das Layout des Textes möglichst originalgetreu erhalten willst.

Link zum Skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/robust-pdf-read/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/robust-pdf-read/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Lies meine Mietvertrags-PDF und gib mir den Text. Der Dateileser zeigt nur verzerrte Zeichen.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Agent prüft die Ausgabe des normalen Lesers auf Binär- oder verzerrte Inhalte. Findet er solche, führt er pdftotext mit Layout-Option und ohne Seitenumbruchzeichen aus und gibt den Text auf die Standardausgabe zur Ansicht.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von 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.
Häufige Fragen

Wie erkennt der Agent einen fehlgeschlagenen Lesevorgang?

Er achtet auf Null-Bytes, Base64-artige Daten oder eindeutig verzerrten Text.

Was bewirken die Optionen von pdftotext?

Die Layout-Option erhält das Seitenlayout, die Option nopgbrk entfernt Seitenumbruchzeichen.

Braucht das eine besondere Installation?

Der Skill sagt, pdftotext gehört zu poppler-utils, das auf Linux-Systemen oft schon installiert ist.

Details

Originalbeschreibung des Autors

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

repo: HKUDS/AgentPilot

Beliebtheit

GitHub-Sterne
7.8k
Platz im Ranking
#12977
Lizenz
MIT
Aktualisiert
1.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills