# Document Gen Resilient Workflow

Multi-engine document generation with cascading PDF fallbacks and robust Unicode handling

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

## Install

Claude Code: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient-workflow -g -a claude-code -y`
Codex: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient-workflow -g -a codex -y`
Cursor: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient-workflow -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient-workflow -g -a gemini-cli -y`

## Description

Multi-engine document generation with cascading PDF fallbacks and robust Unicode handling

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

# Resilient Document Generation Workflow (Multi-Engine Fallback)

## When to Use

Use this skill when document generation tasks fail or when `shell_agent` returns unknown errors, especially for:
- Generating documents in multiple formats (`.docx`, `.pdf`, `.html`)
- **PDF generation fails due to missing LaTeX, encoding issues, or tool errors**
- Documents contain special characters, symbols, or non-ASCII text
- You need maximum reliability with automatic fallback options

## Core Technique

Split document generation into discrete, observable steps with **cascading fallbacks** for PDF generation:
1. **Content creation** → Use `write_file` to create source Markdown
2. **Unicode sanitization** → Use Python script for reliable character replacement
3. **Format conversion** → Try multiple PDF engines in sequence until one succeeds
4. **Verification** → Check file exists, has non-zero size, and is valid

## ⚠️ Unicode & PDF Engine Guide

Different PDF engines have different Unicode support:

| Engine | Unicode Support | Best For | Fallback Position |
|--------|----------------|----------|-------------------|
| `pdflatex` | Limited (ASCII-focused) | Simple documents | 1st (fastest) |
| `xelatex` | Full Unicode | Documents with non-ASCII | 2nd |
| `wkhtmltopdf` | Good Unicode | Web-style documents | 3rd |
| `reportlab` (Python) | Full control | Programmatic PDFs | 4th |
| `fpdf2` (Python) | Full control | Simple text PDFs | 5th (last resort) |

### Character Replacement Table

The rest: https://github.com/HKUDS/AgentPilot/blob/HEAD/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-2794b4/SKILL.md
