# Document Gen Resilient Multiformat

Resilient multi-format document generation with environment checks, auto-sanitization...

- Repository: https://github.com/HKUDS/AgentPilot (7784 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

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

## Description

Resilient multi-format document generation with environment checks, auto-sanitization, and fallback engines

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

# Resilient Document Generation Workflow (Multi-Format + Unicode-Safe)

## When to Use

Use this skill when generating documents in multiple formats (`.docx`, `.pdf`, `.html`) and you need:
- **Reliable execution** with pre-flight environment verification
- **Automatic Unicode handling** based on target format
- **Fallback options** when primary tools (pandoc/LaTeX) are unavailable
- **Clear error isolation** through discrete, observable steps

**Trigger this workflow when:**
- `shell_agent` returns unknown/unclear errors on document generation
- You need multiple output formats from one source
- Documents contain special characters, symbols, or non-ASCII text
- Previous PDF generation attempts failed due to encoding or missing dependencies

## Pre-Flight Environment Check

**Before starting**, verify your environment has the required tools:

```
run_shell
command: which pandoc && pandoc --version | head -1
```

```
run_shell
command: which pdflatex || which xelatex || which wkhtmltopdf || echo "No PDF engine found"
```

```
run_shell
command: python3 -c "import fpdf; print('fpdf2 available')" 2>/dev/null || echo "fpdf2 not available"
```

```
run_shell
command: python3 -c "import reportlab; print('reportlab available')" 2>/dev/null || echo "reportlab not available"
```

**If pandoc is missing:** Install via `apt-get install pandoc` or `brew install pandoc`

**If no PDF engine found:** Choose fallback approach:
- Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`
- Or use wkhtmltopdf: `apt-get install wkhtmltopdf`
- Or use Python fallback (fpdf2/reportlab) - see Alternative PDF Generation section

## Core Technique

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