WolfDocx documentation - Community
Install WolfDocx and edit your first Word document
Install WolfDocx Community with pip install wolfdocx to edit an existing .docx in Python. Open the file with Document, inspect its paragraphs, apply a supported edit, and check the save receipt. Rendering, PDF conversion, and the Commercial workflows documented separately are not included in this package.
Install the Community package
WolfDocx Community is the public, MIT-licensed wolfdocx package. Version 0.1.0 requires Python 3.11 or newer and ships as a pure-Python wheel. Use a separate virtual environment for each edition: Community and Commercial both install under the name wolfdocx from different indexes, so the import name alone does not identify the installed distribution.
The commands below are for bash or zsh. They install Community into a local environment without activating it or changing your shell configuration. Run them in your project directory. For another shell, use its equivalent interpreter path rather than copying shell activation syntax.
python3 -m venv .venv
.venv/bin/python -m pip install wolfdocx==0.1.0
.venv/bin/python quickstart.pyThe pinned install makes this example reproducible. The unpinned public installation is pip install wolfdocx. The PyPI release and Community source describe that distribution, not the private Commercial engine.
Open, read, edit, and save
Start with input.docx containing the text Hello. Save the following Python as quickstart.py and run it with the environment's Python. The output output.docx must not already exist. This is an edit to an existing package, not a blank-document builder.
from wolfdocx import Document, NodeType
with Document("input.docx") as doc:
for paragraph in doc.node.get_child_nodes(NodeType.PARAGRAPH, deep=True):
print(paragraph.get_text())
edit = doc.find_replace("Hello", "Hi")
if not edit.passed:
raise SystemExit(edit.code)
saved = doc.save("output.docx")
if not saved.passed:
raise SystemExit(saved.code)
print(saved.status, saved.changed_parts)NodeType.PARAGRAPH selects paragraphs and deep=True includes descendants such as paragraphs inside tables. The text view includes paragraph terminators. It is useful for inspection, but it does not describe rendered line breaks or physical page locations.
The replacement is a regular expression. This example uses an ordinary word, but punctuation in a literal search should be escaped with Python's re.escape. Check the edit report before saving: a pattern with no replacement refuses with find_replace_no_match, rather than reporting a successful change.
Editing changes the session. save then publishes the new package and returns a separate receipt. Checking only the replacement report would miss a save failure such as an occupied destination. Keep the input as the reviewed source and choose a new output name for another run.
Choose the right edition
Community handles supported, targeted edits to existing DOCX files. Commercial uses a commercial license and is installed as wolfdocx through an authenticated index with the credential from the checkout success page. It is not an extra unlocked by installing the public package.
python -m pip install wolfdocx --index-url https://packages.wolfxl.com/wolfdocx/simple/This Commercial command is for bash or zsh after configuring pip authentication with the credential from the checkout success page. Both editions install under the name wolfdocx from different indexes; an environment holds one or the other.
Use a separate Commercial environment for document assembly, mail merge, and field-refresh examples in these docs. Page-dependent field refresh needs the Commercial layout workflow and explicit fonts. DOCX-to-PDF is also a Commercial or Wolf Runtime task, not a Community export option.
What it does not do
- This quickstart does not create a Word document from scratch.
- Community does not render pages or convert a DOCX to PDF.
- A saved package is not a promise of identical pagination in every Word installation.
- A refusal must be handled, not treated as an empty successful result.
Next steps
Continue with reading document content, editing text and tables, or the task guide for replacing text in a Word report.