direct-reportlab-pdf-generation
Qué hace
Esta skill muestra a la IA cómo crear un PDF con una maquetación precisa escribiendo y ejecutando código de ReportLab. Está pensada para quienes necesitan informes de varias páginas o documentos estructurados en PDF.
Cuándo usarla
- ✓Cuando necesito un PDF largo con títulos, tablas, imágenes y saltos de página.
- ✓Cuando un agente auxiliar sigue fallando al crear mi documento PDF.
- ✓Cuando necesito un control detallado de cómo se maqueta el PDF.
Link de la skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/direct-reportlab-pdf-generation/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
“Quiero un informe en PDF de varias páginas con portada, tablas y secciones, hecho con ReportLab. ¿Puedes crearlo?”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La IA organiza el contenido en secciones, escribe un script de Python que usa la biblioteca ReportLab y lo ejecuta para producir el archivo PDF.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Direct ReportLab PDF Generation via run_shell
When to Use This Skill
Use this pattern when:
- You need to create a complex, multi-page PDF document with structured content
- Delegating PDF generation to
shell_agentfails or produces unreliable results - You need fine-grained control over PDF layout, styling, and pagination
Core Technique
Instead of asking shell_agent to handle PDF creation, write inline Python code using the reportlab library and execute it directly via run_shell. This gives you deterministic control over the document structure.
Step-by-Step Instructions
Step 1: Prepare Your PDF Content
Organize your content into logical sections that will become pages or page groups:
- Title page
- Table of contents (optional)
- Main content sections
- Appendices or references
Step 2: Write the ReportLab Python Script
Create a Python script that uses these key reportlab components:
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak, Image
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
def create_pdf(filename, content_data):
doc = SimpleDocTemplate(filename, pagesize=letter,
rightMargin=72, leftMargin=72,
topMargin=72, bottomMargin=72)
story = []
styles = getSampleStyleSheet()
# Custom styles
title_style = ParagraphStyle(
'CustomTitle',
parent=styles['Heading1'],
fontSize=24,
textColor=colors.HexColor('#1a1a1a'),
spaceAfter=30,
alignment=TA_CENTER
)
heading_style = ParagraphStyle(
'CustomHeading',
parent=styles['Heading2'],
fontSize=16,
textColor=colors.HexColor('#2c3e50'),
spaceBefore=20,
spaceAfter=12
)
body_style = ParagraphStyle(
'CustomBody',
parent=styles['Normal'],
fontSize=11,
leading=16,
alignment=TA_JUSTIFY
)
# Build document content
for section in content_data:
if section['type'] == 'title':
story.append(Paragraph(section['text'], title_style))
elif section['type'] == 'heading':
story.append(Paragraph(section['text'], heading_style))
elif section['type'] == 'paragraph':
story.append(Paragraph(section['text'], body_style))
story.append(Spacer(1, 12))
elif section['type'] == 'table':
table = Table(section['data'], colWidths=section.get('col_widths'))
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 12),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
('GRID', (0, 0), (-1, -1), 1, colors.black),
]))
story.append(table)
story.append(Spacer(1, 20))
elif section['type'] == 'pagebreak':
story.append(PageBreak())
doc.build(story)
Step 3: Execute via run_shell
Run the Python script directly using run_shell:
python3 << 'EOF'
# Your complete reportlab script here
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
# ... rest of your script
EOF
Or save to a file and execute:
cat > generate_pdf.py << 'SCRIPT'
# Your complete script
SCRIPT
python3 generate_pdf.py
Step 4: Handle Complex Content
For lengthy documents, structure content as a data structure:
document_sections = [
{'type': 'title', 'text': 'Document Title'},
{'type': 'pagebreak'},
{'type': 'heading', 'text': 'Section 1'},
{'type': 'paragraph', 'text': 'Content here...'},
{'type': 'heading', 'text': 'Section 2'},
{'type': 'table', 'data': [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]},
{'type': 'pagebreak'},
#
Preguntas frecuentes
¿Qué es ReportLab?
Es una biblioteca de Python para crear archivos PDF con texto, tablas e imágenes.
¿Necesito saber Python?
La skill incluye código de ejemplo, pero para ejecutarlo hace falta tener Python y la biblioteca ReportLab instaladas.
¿Se incluye un índice?
El plan de contenido incluye un índice como opcional.
Detalles
Descripción original del autor
Generate complex multi-page PDFs by running reportlab Python code directly via run_shell when shell_agent fails on document creation
repo: HKUDS/AgentPilot
Popularidad
- Estrellas en GitHub
- 7,8 mil
- Posición en el ranking
- #12855
- 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.