Word Document Generation and Editing
Paste the following prompt into your AI chat to install this skill:
Please follow https://skillhub.cn/install/skillhub.md and install @user_24e9cdd5/docx-generator-plus.
About this skill
Problem
Generating .docx files can fail in subtle ways once opened in Word: page size, table width, list styling, image scaling, page breaks, and TOC fields may not match expectations. Editing raw XML or doing string replacement is fragile because Word splits text into runs, adds revision marks, and applies style-dependent formatting. This skill frames the work as create, edit, read, and validate, giving engineers a practical code path for stable document output.
How It Works
- Create documents: prefer
python-docx; the templatereferences/docx_template.pycovers headings, nested headings, tables, lists, footers, and page numbers. Thenpm docxpackage is another option. - Edit existing files: open an existing
.docxwithDocument('existing.docx')to append or modify content, or unzip the package, updateword/document.xml, and repackage it. - Read content: iterate over
document.paragraphs, or convert withpandoc -t markdown file.docxfor easier parsing. - Validate output: convert the result to PDF to inspect layout, and use LibreOffice when converting legacy
.docfiles. Key details include usingInchesfor page dimensions,table.autofitor explicit column widths,List Bulletstyles instead of literal bullets,WD_BREAK.PAGEfor page breaks, and paragraph borders instead of table separators. For text replacement, iteraterun.textvalues to avoid regex failures across split runs.
Boundaries
This is useful for programmatic submission documents, outline tables, contracts, resumes, and template-driven Word output. It is not a substitute for complex Office workflows such as mail merge, comments, approval chains, or Word plugin interactions. Optional tooling may be required for legacy .doc conversion and PDF validation.
Use Cases
- Generate weekly project reports as .docx with headings, body text, tables, and page-number footers.
- Turn novel outlines into a Word table listing chapters, conflicts, hooks, and word counts.
- Extract paragraphs from an existing .docx and convert them to Markdown for risk review.
- Edit contract clauses in an existing .docx by updating run text instead of whole-paragraph regex.
Best For
- Backend engineers who need to render structured data into formal Word documents.
- Office automation engineers maintaining contract and resume templates with batch field replacement.
- Editors who format long manuscripts with headings, tables, and page numbers for submission.
- Technical writers extracting old .docx content and converting it to Markdown for knowledge bases.
Related Skills
Generate and edit .pptx decks with python-pptx, applying structured layouts, design rules, native charts, and visual QA to reduce template-like output.
Tencent Cloud Table Recognition V3 is an OCR skill for detecting and recognizing tables in images or PDFs, supporting various table types like linear and borderless tables, with Excel export.
The complete set of online document operation tools provided by Tencent Docs MCP, supporting creation, querying, and editing of smart docs, Excel, PPT, mind maps, and more.
Turn a topic, notes, or tables into a complete PPT plan with logic, page layouts, visual and chart guidance, and natural defense scripts.