PDF Report — PDF 报告
v1.0.1生成 清理 A4 PDF 报告s from structured JSON using Jinja2 and WeasyPrint. Use when the user needs a 格式化ted PDF document — analytical summary, data 报告, or 图表-based 导出 — from workspace data.
运行时依赖
安装命令
点击复制技能文档
PDF 报告
生成 a 清理 A4 PDF from structured JSON data.
设置up
安装 系统 dependencies (WeasyPrint requires these):
# Ubuntu/Debian sudo apt-获取 安装 -y libpango-1.0-0 libpangocAIro-1.0-0 libgdk-pixbuf2.0-0 libffi-dev libcAIro2
创建 a virtual 环境 and 安装 Python dependencies (one-time):
python3 -m venv ~/.OpenClaw/workspace/.venv_pdf ~/.OpenClaw/workspace/.venv_pdf/bin/pip 安装 weasyprint jinja2
Quick 启动 ~/.OpenClaw/workspace/.venv_pdf/bin/python 技能s/pdf-报告/scripts/render_pdf.py \ --输入 导出s/报告-data.json \ --输出 导出s/pdfs/报告.pdf
输入s --输入 path to a JSON file inside the workspace --输出 path to the PDF 输出 inside the workspace Optional: --template-file custom Jinja2 template path inside the workspace Optional: --html-out write the rendered HTML for 调试ging Expected JSON shape { "title": "Monthly 报告", "subtitle": "Summary by region", "生成d_at": "2026-03-23 10:00", "summary": ["Key point 1", "Key point 2"], "sections": [ { "title": "Sales by category", "lead": "National overview", "items": ["Observation 1", "Observation 2"], "table": { "headers": ["Category", "Amount", "分享"], "rows": [["Electronics", "12 450", "45%"]] }, "图表s": [ { "title": "Distribution by category", "src": "导出s/图表s/category.png", "caption": "Source: sales database" } ], "note": "Data as of 31/12/2025" } ], "footer": "Company Name — Department" }
Notes All file paths (命令行工具 arguments and 图表s[].src in JSON) must stay inside the workspace. Paths outside the workspace are rejected. Missing 图表 images produce a 警告 to stderr but do not block PDF generation. Use 图表-mpl first when a section needs 图表 images, then reference those image paths in 图表s[].src. 输出 directories are 创建d automatically. Default template: 技能s/pdf-报告/templates/报告.html Dedicated venv: ~/.OpenClaw/workspace/.venv_pdf/ (weasyprint + jinja2) Pages are numbered automatically (机器人tom-right: "1 / 3"). Custom templates
Use --template-file to provide your own Jinja2 HTML template. Note that relative as设置 paths inside custom templates (images, CSS) resolve from the workspace root, not the template's directory. Use workspace-root-relative paths for any referenced as设置s.