WolfDocx documentation - Community
WolfDocx documentation: edit existing Word documents with Python
Start with WolfDocx Community to read and make supported edits to an existing DOCX in Python. Install the public MIT package with pip install wolfdocx, then open, edit, and save a new file. The Commercial installation comes from an authenticated index and adds the separately labeled workflows in these docs.
Start with the package you actually have
Community 0.1.0 is the public, pure-Python wolfdocx package for Python 3.11 or newer. It edits existing documents; it does not render pages or convert them to PDF. The public PyPI release is MIT licensed, and its source and tests define the Community APIs used here.
Commercial also installs under the name wolfdocx, but from an authenticated product index with the credential from the checkout success page. An environment holds one edition or the other. A shared installation name does not mean that a Community environment provides Commercial document assembly, mail merge, or layout APIs.
Each topic labels its sample's edition. Begin with the Community quickstart if your task is an ordinary supported edit. Read the Commercial prerequisites before copying an assembly or field-refresh example. Do not diagnose a missing Commercial symbol by repeatedly reinstalling the public Community package.
Read an existing document first
After installing Community with pip install wolfdocx, put a reviewed Word file at input.docx and run this Python. It prints paragraph text without saving or changing the file. Inspecting the source first helps distinguish a paragraph replacement, a specific table-cell update, and a field whose cached result needs a different operation.
from wolfdocx import Document, NodeType
with Document("input.docx") as doc:
for paragraph in doc.node.get_child_nodes(NodeType.PARAGRAPH, deep=True):
print(repr(paragraph.get_text()))The recursive paragraph view includes paragraphs within tables, and its text contains structural terminators. It is not a page renderer or a guarantee that every visible document feature has been flattened into a plain-text transcript. Keep that distinction when building extraction or update pipelines.
Community: install, inspect, and edit
- Installation and quickstart: choose an edition, open a reviewed source, replace text, and check the save receipt.
- Reading paragraphs and tables: traverse the document tree without treating structural text as rendered pages.
- Editing text and table cells: use regex replacement or one-based cell coordinates with an expected-value guard.
- Reports, refusals, and command-line use: distinguish an accepted session edit from a published output; the CLI section is Commercial.
Commercial: populate, assemble, and refresh
- Templates and mail merge: distinguish literal placeholders, repeated structures, and recipient MERGEFIELD workflows.
- Merging documents: import existing DOCX packages in order and choose the style collision policy.
- Fields and table of contents: refresh supported caches with explicit fonts and native pagination, not Microsoft Word evaluation.
For a concrete task, use the text-replacement guide, table-update guide, or document-merge guide. The source-backed API reference covers the Commercial engine and should not be read as a Community export list.
Example projects
Each project is a complete folder you can run: a self-made sample document, the script that edits it, a requirements.txt that pins the Wolf release and every dependency with hashes, and the output the run prints. Download the zip, or read every file in the one-page Markdown source listing.
- Contract redline proposed by an agent loop (wolfdocx==0.1.1): An agent reads a playbook and a supplier contract through four tools, proposes edits by quoting text, and WolfDocx writes them as native Word tracked changes; runs from a recorded tool-call replay without an API key, or live against the Anthropic API. Download docx-redline-agent.zip or read the source listing.
- Fill a Word template (wolfdocx==0.1.1): Fills {{placeholders}} in an engagement letter from data.json, repeats the fee table's line-item row, refuses a template and data mismatch, and checks that no placeholder is left. Download docx-template-fill.zip or read the source listing.
- Edit a 1,000-page Word document (wolfdocx==0.1.1): Renames a counterparty and a rate-card year on all 1,000 pages of a services agreement, updates one price in the last rate table, and recounts pages, paragraphs and tables in the saved file. Download docx-large-document.zip or read the source listing.
What it does not do
- Community does not render pages, thumbnails, or PDF output.
- Successful package editing does not establish identical Microsoft Word pagination.
- A refusal is a supported boundary to handle, not an instruction to suppress a warning.
- These docs do not promise arbitrary Word features are editable. Each operation has its own scope.
Keep the reviewed source, choose a new destination, and check each operation's report. Where page layout matters, use the labeled Commercial or Wolf Runtime workflow and retain the actual font inputs. Structural preservation and visual comparison answer different questions; neither should silently stand in for the other.