pdf-generation-troubleshooting
Qué hace
Esta skill es un plan de tres pasos para crear PDF que pasa de pandoc a bibliotecas de Python. Está pensada para quienes convierten Markdown o crean PDF cuando algunas herramientas pueden faltar.
Cuándo usarla
- ✓Cuando tengo un archivo Markdown o HTML que debe convertirse en PDF.
- ✓Cuando pandoc falta o falla en la conversión.
- ✓Cuando necesito crear un PDF desde cero con Python porque las demás herramientas no están disponibles.
Link de la skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-generation-troubleshooting/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
“Convierte este Markdown en un PDF. Si pandoc no está disponible aquí, usa una biblioteca de Python.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La IA comprueba si existe pandoc y convierte si está presente. Si no, comprueba reportlab y lo instala si hace falta y, por último, prueba fpdf2.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
PDF Generation Troubleshooting Workflow
This skill provides a systematic approach to generating PDFs when multiple tools may be unavailable. Follow this fallback sequence to ensure PDF generation succeeds.
Workflow Overview
- Try pandoc first (simplest for markdown/HTML conversion)
- Fallback to reportlab (Python library for programmatic PDFs)
- Fallback to fpdf2 (alternative Python PDF library)
Each step includes installation verification before execution.
Step 1: Attempt pandoc Conversion
Use pandoc for markdown or HTML to PDF conversion. Check availability first:
# Check if pandoc is available
which pandoc || echo "pandoc not found"
If available, convert:
pandoc input.md -o output.pdf
If pandoc fails or is unavailable, proceed to Step 2.
Step 2: Attempt reportlab
Check Installation
python3 -c "import reportlab" 2>/dev/null && echo "reportlab available" || echo "reportlab not found"
Install if Needed
pip install reportlab
Create PDF Script
Use write_file to create a Python script:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
def create_pdf(filename, content):
c = canvas.Canvas(filename, pagesize=letter)
c.drawString(100, 750, content)
c.save()
if __name__ == "__main__":
create_pdf("output.pdf", "Your content here")
Execute Script
Use run_shell with proper directory context:
cd /path/to/working/directory && python3 script.py
If reportlab fails, proceed to Step 3.
Step 3: Attempt fpdf2
Check Installation
python3 -c "from fpdf import FPDF" 2>/dev/null && echo "fpdf2 available" || echo "fpdf2 not found"
Install if Needed
pip install fpdf2
Create PDF Script
from fpdf import FPDF
def create_pdf(filename, text):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(200, 10, txt=text, ln=True)
pdf.output(filename)
if __name__ == "__main__":
create_pdf("output.pdf", "Your content here")
Execute Script
cd /path/to/working/directory && python3 script.py
Decision Matrix
| Tool | Best For | Limitations |
|---|---|---|
| pandoc | Markdown/HTML conversion | Requires external installation |
| reportlab | Complex layouts, graphics | Steeper learning curve |
| fpdf2 | Simple text PDFs | Limited formatting options |
Error Handling Pattern
For each tool attempt:
- Check availability/installation
- Install if missing (
pip install <package>) - Create script using
write_file - Execute using
run_shellwithcd <dir> && <command> - Verify output file exists
- If fails, move to next tool in sequence
Example Fallback Implementation
# Pseudocode for full workflow
if command -v pandoc >/dev/null 2>&1; then
pandoc input.md -o output.pdf && exit 0
fi
if python3 -c "import reportlab" 2>/dev/null; then
# Create and run reportlab script
exit 0
fi
# Final fallback: fpdf2
pip install fpdf2
# Create and run fpdf2 script
Key Principles
- Always verify tool availability before attempting use
- Install on-demand when a tool is missing
- Use write_file for script creation (ensures clean, versionable code)
- Use run_shell with explicit directory context (
cd <dir> && <cmd>) - Progressive fallback ensures at least one method succeeds
- Verify output after each attempt before moving to next tool
Preguntas frecuentes
¿Cuál es la primera opción?
Pandoc, que es la opción más sencilla para archivos Markdown o HTML.
¿Qué viene después de pandoc?
Reportlab, una biblioteca de Python, y después fpdf2 si reportlab no funciona.
¿Se comprueban las herramientas antes de usarlas?
Sí. Cada paso comprueba la instalación antes de ejecutarse.
Detalles
Descripción original del autor
Systematic fallback workflow for PDF generation through pandoc, reportlab, and fpdf2 with installation verification
repo: HKUDS/AgentPilot
Popularidad
- Estrellas en GitHub
- 7,8 mil
- Posición en el ranking
- #12929
- 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.