robust-pdf-read
What it does
This skill shows the AI agent how to pull readable text out of a PDF with the pdftotext tool. It is for people whose PDF reading comes back as unreadable characters.
When to use it
- ✓When the file reader returns raw binary, base64 image data or garbled characters for a PDF.
- ✓When you need the words from a PDF in plain text to work with.
- ✓When you want the layout of the PDF's text kept as close to the original as possible.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/robust-pdf-read/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Read my lease PDF and give me the text. The file reader only shows garbled characters.”
5 new skills a week. 1 minute to read.
How it works
The agent checks the output of the normal reader for binary or garbled content. If it finds that, it runs pdftotext with layout options and no page break characters, and sends the text to standard output for reading.
Technical content (original SKILL.md)
Original text by the author, straight from 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
pdftotextinstalled (usually viapoppler-utils). - If
pdftotextis 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.
FAQ
How does the agent spot a failed read?
It looks for null bytes, base64-looking data or text that is clearly garbled.
What do the pdftotext options do?
The layout option keeps the page layout, and the nopgbrk option removes page break characters.
Does this need a special install?
The skill says pdftotext is part of poppler-utils, which is often already installed on Linux systems.
Details
Original description by the author
Reliably extract text from PDFs using pdftotext when standard file reading fails.
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12977
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.