office-document-generation
Use when producing .docx/.pdf/.md deliverables and files.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- office-document-generation
- version
- 1.0.0
- metadata
- { "hermes": { "tags": [ "docx", "pdf", "markdown", "documents", "deliverables", "python-docx", "fpdf2" ] } }
- description
- Use when producing .docx/.pdf/.md deliverables and files.
03 SKILL.md 正文
Office Document Generation (.docx / .pdf / .md)
Produce polished, downloadable document deliverables — reports, briefings, resumes, job descriptions, bios — as Word (.docx), PDF, and Markdown, and send the files in chat.
When to Use
- The user asks for a document "as a .docx / .pdf / Word file".
- A recurring report or briefing must ship as formatted attachments.
- Any deliverable where one body of content must exist in several formats.
Toolchain
python3 -m pip install python-docx fpdf2 # docx + pdf writers
# poppler's `pdftotext` (usually preinstalled) extracts PDF text for verification
Procedure
- Define content once, render to every format. Write one build script (
build_<name>.py): the top holds the content as data (title, contact line, sections, bullet lists); the body renders that same data to.md,.docx, and.pdf. Never hand-edit an output — rerun the script so the three formats cannot drift apart. - DOCX (
python-docx): set theNormalstyle font/margins and a section-heading helper (bold, colored, bottom rule via aw:pBdr/w:bottomXML snippet). - PDF (
fpdf2): register a Unicode font first (pitfall 1), then write headings, paragraphs, and bullets. Set an explicit content width once and reuse it. - Verify by extracting the produced files (see Verification) — not by trusting the build log.
- Deliver every file with an absolute
MEDIA:line in the chat response. - Governance: file writes are gated —
begin_changefirst; score with real numbers atend_change(a bare note may be refused — supply completeness/quality/progress, or anunscored_reason).
Pitfalls
- fpdf2 core fonts are Latin-1 only. An en dash (–), em dash, curly quote, or other non-ASCII
character raises
FPDFUnicodeEncodingException/UnicodeEncodeErrormid-render. Register a Unicode TTF and use it everywhere:pdf.add_font("DejaVu", "", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")plus the-Boldfile for the"B"style, thenset_font("DejaVu", ...). DejaVu ships on most Linux hosts; Ubuntu/Noto TTF work too. - fpdf2
multi_cellleaves the cursor mid-line, so the NEXT cell starts at the wrong x and text truncates or wraps wrongly — symptoms:Not enough horizontal space to render a single character, or a line cut down to a few words. Callpdf.set_x(pdf.l_margin)before everymulti_cell(or pass an explicit width). For inline bold within one line, usepdf.write()for both runs, thenpdf.ln(). - Uppercased section headings defeat mixed-case verification. Headings rendered via
.upper()(a common docx/PDF section style) will not match a grep for "Professional Experience" even when the document is correct. Verify against the UPPERCASED string, or search case-insensitively. - A clean build is not correct content — always extract and grep the produced file.
- Blank-render check: print byte sizes (a few hundred bytes = empty/failed). For transparent PNGs count alpha, not colour — a white mark on transparency looks "empty" to a colour test.
Verification
- DOCX:
"\n".join(p.text for p in Document(path).paragraphs)— assert each section marker present. - PDF:
pdftotext file.pdf -(or pymupdf) — assert each marker present; magic bytes start%PDF-. - MD: read the file and assert markers.
Delivery in chat
- One
MEDIA:/absolute/path/file.extline per file; reference only files that exist. - Telegram:
.png/.jpgarrive as photos;.docx,.pdf,.md,.svgarrive as documents.
04 同仓库更多 Skills
macbook-linux-maintenance
Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.
governance-regression-triage
Triage a host's governance issues: what changed.
enforcement-immutability
Use when enforcement files lose their immutable flag.
steadfaste-fleet-repo-deploy
Use when committing to the steadfaste-fleet repo.
steadfaste-fleet-maintenance
Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.
fleet-preflight
DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its "Repo-Specific Pre-Flight" section covers git search, Hermes boundary, and deployment verification.