# Direct Reportlab PDF Generation

Generate complex multi-page PDFs by running reportlab Python code directly via...

- Repository: https://github.com/HKUDS/AgentPilot (7784 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add HKUDS/AgentPilot --skill direct-reportlab-pdf-generation -g -a claude-code -y`
Codex: `npx skills add HKUDS/AgentPilot --skill direct-reportlab-pdf-generation -g -a codex -y`
Cursor: `npx skills add HKUDS/AgentPilot --skill direct-reportlab-pdf-generation -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/AgentPilot --skill direct-reportlab-pdf-generation -g -a gemini-cli -y`

## Description

Generate complex multi-page PDFs by running reportlab Python code directly via run_shell when shell_agent fails on document creation

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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_agent` fails 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:

```python
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

The rest: https://github.com/HKUDS/AgentPilot/blob/HEAD/openspace/benchmarks/gdpval/skills/direct-reportlab-pdf-generation/SKILL.md
