pdf-text-extraction-fallback
Qué hace
Esta skill explica cómo extraer texto de PDF con pdftotext cuando falla el lector de archivos integrado. Está pensada para quienes trabajan con PDF que contienen imágenes o un formato complejo.
Cuándo usarla
- ✓Cuando leer un PDF devuelve datos binarios o de imagen.
- ✓Cuando el PDF incluye imágenes incrustadas o un formato complejo.
- ✓Cuando necesito texto legible del PDF para usarlo en mi tarea.
Link de la skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-text-extraction-fallback/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“El lector de archivos me devuelve datos binarios de mi PDF. Revisa los parámetros de la llamada y extrae el texto con pdftotext.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La IA se asegura de que la llamada de lectura usa el nombre de parámetro correcto, detecta la salida binaria y después ejecuta pdftotext para mostrar el texto por la salida estándar.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
PDF Text Extraction Fallback
When to Use This Skill
Use this skill when read_file with filetype="pdf" returns binary/image data instead of readable text content. This is a common issue with PDF files that contain embedded images or complex formatting.
Steps
1. Validate Parameters First
Before attempting extraction, ensure you're using the correct parameter name:
- Use
filetype(notfile_type) for theread_filefunction - Incorrect parameter names can cause silent failures
# Correct
read_file(filetype="pdf", file_path="document.pdf")
# Incorrect - may fail silently
read_file(file_type="pdf", file_path="document.pdf")
2. Detect Binary Data Issue
After calling read_file, check if the result contains:
- Garbled/binary characters
- Image data representations (e.g.,
b'...'byte strings with non-text content) - Unreadable or corrupted-looking content
If yes, proceed with the pdftotext workaround.
3. Extract Text via pdftotext
Use run_shell to call pdftotext, which extracts text directly from PDF files:
# Extract text to stdout
result = run_shell(command="pdftotext /path/to/document.pdf -")
text_content = result.stdout
The - flag tells pdftotext to output to stdout instead of creating a file.
4. Handle Output and Errors
result = run_shell(command="pdftotext /path/to/document.pdf -")
if result.stderr:
# Check for errors like "pdftotext not found"
# May need to install poppler-utils
pass
text_content = result.stdout
# text_content now contains the extracted text
Example Workflow
# Step 1: Try normal read with correct parameters
content = read_file(filetype="pdf", file_path="reference.pdf")
# Step 2: Check if content is readable
if not content or looks_like_binary(content):
# Step 3: Fall back to pdftotext
result = run_shell(command="pdftotext reference.pdf -")
text_content = result.stdout
# Step 4: Verify extraction succeeded
if result.stderr:
# Handle error (e.g., install pdftotext)
pass
Installation Notes
pdftotext is part of the poppler-utils package:
- Debian/Ubuntu:
apt-get install poppler-utils - macOS:
brew install poppler - Many Linux environments: Pre-installed
Alternative: Output to File
If stdout approach has issues, output to a temporary file:
run_shell(command="pdftotext /path/to/document.pdf /tmp/output.txt")
text_content = read_file(filetype="txt", file_path="/tmp/output.txt")
Best Practices
- Always validate the
filetypeparameter spelling before troubleshooting - Check both stdout and stderr from pdftotext
- For multi-page PDFs, pdftotext preserves page breaks with form feeds
- This method works better for text-based PDFs than image-scanned PDFs
Preguntas frecuentes
¿Por qué importa el nombre del parámetro?
La guía indica que un nombre de parámetro incorrecto puede causar fallos silenciosos.
¿Cómo se detecta la salida binaria?
Busca caracteres binarios o marcas de datos de imagen en el resultado.
¿Qué hace el guion en el comando?
Indica a pdftotext que muestre el texto en pantalla en lugar de guardarlo en un archivo.
Detalles
Descripción original del autor
Extract text from PDFs using pdftotext when read_file returns binary data
repo: HKUDS/AgentPilot
Popularidad
- Estrellas en GitHub
- 7,8 mil
- Posición en el ranking
- #12934
- Licencia
- MIT
- Actualizada
- 1/11/2026
Comentarios
- …
Más skills de este repositorio
agentpilot
7,8 milAyuda a tu agente a mejorar un proyecto paso a paso, preparando una tarea y ejecutando el bucle de AgentPilot que propone, prueba y puntúa cambios.
openspace
7,8 milAyuda a tu agente a configurar OpenSpace, una herramienta que guarda y recupera skills de agentes, y a conectarla a tu app de IA mediante MCP.
rsi-arena
7,8 milAyuda a tu agente a configurar y ejecutar pruebas de referencia de IA conocidas, como AIME y Terminal-Bench, para comparar distintos métodos de mejora.
experiment-guide
7,8 milAyuda a tu agente a planificar experimentos pequeños, leer sus resultados y anotar conclusiones mientras investiga cómo mejorar un programa.
Skills parecidas
feishu-doc
394 milAyuda a tu agente a leer, crear y editar documentos en la nube de Feishu, incluidos texto, imágenes y tablas, usando la herramienta de documentos.
feishu-drive
394 milPermite que tu agente explore, organice y comente archivos de una carpeta de la nube de Feishu que se haya compartido con el bot.
feishu-perm
394 milAyuda a tu agente a revisar y cambiar quién puede acceder a un archivo de Feishu, eligiendo el permiso más pequeño que cumpla tu petición.