An import-compatible, agent-safe fork of python-docx for creating and editing Word documents without silent corruption.
paper-docx is an import-compatible hard fork of python-docx for creating and editing Microsoft Word (.docx) documents. It keeps the docx import name and upstream object model, and adds guarded inspection and editing APIs that refuse unsupported operations instead of guessing.
Use an activated virtual environment.
python -m pip uninstall -y python-docx paper-docx
python -m pip install paper-docx
python -m paper_docx_doctor
Both distributions provide the docx import package. Do not install python-docx and paper-docx in the same environment.
To return to python-docx, run the uninstall line above again, then python -m pip install python-docx.
Create a Word redline from two document versions:
import docx
from docx.package import compare
original = docx.Document()
original.add_paragraph("Payment is due within thirty calendar days.")
original.save("original.docx")
revised = docx.Document()
revised.add_paragraph("Payment is due within thirty business days.")
revised.save("revised.docx")
result = compare("original.docx", "revised.docx", author="Reviewer")
result.document.save("redline.docx")
print(result.revision_count) # 2
compare writes differences as tracked changes and refuses changes it cannot represent safely.
Read the paper-docx documentation.
Contributions are welcome. See CONTRIBUTING.md.
paper-docx builds on python-docx by Steve Canny and contributors. This fork preserves their API, license, and attribution.
If you reference paper-docx in research or writing:
@software{paper_docx,
title = {paper-docx: an agent-first structure editor for Word documents},
author = {{Paper Instruments, Inc.}},
year = {2026},
url = {https://github.com/paper-instruments/paper-docx}
}
Cite it as a fork of python-docx by Steve Canny and contributors.
MIT, inherited from python-docx. Original work © Steve Canny and the python-docx contributors; fork additions © Paper Instruments, Inc. See LICENSE.
Python
96.7%
Gherkin
3.2%
An import-compatible, agent-safe fork of python-docx for creating and editing Word documents without silent corruption.
paper-docx is an import-compatible hard fork of python-docx for creating and editing Microsoft Word (.docx) documents. It keeps the docx import name and upstream object model, and adds guarded inspection and editing APIs that refuse unsupported operations instead of guessing.
Use an activated virtual environment.
python -m pip uninstall -y python-docx paper-docx
python -m pip install paper-docx
python -m paper_docx_doctor
Both distributions provide the docx import package. Do not install python-docx and paper-docx in the same environment.
To return to python-docx, run the uninstall line above again, then python -m pip install python-docx.
Create a Word redline from two document versions:
import docx
from docx.package import compare
original = docx.Document()
original.add_paragraph("Payment is due within thirty calendar days.")
original.save("original.docx")
revised = docx.Document()
revised.add_paragraph("Payment is due within thirty business days.")
revised.save("revised.docx")
result = compare("original.docx", "revised.docx", author="Reviewer")
result.document.save("redline.docx")
print(result.revision_count) # 2
compare writes differences as tracked changes and refuses changes it cannot represent safely.
Read the paper-docx documentation.
Contributions are welcome. See CONTRIBUTING.md.
paper-docx builds on python-docx by Steve Canny and contributors. This fork preserves their API, license, and attribution.
If you reference paper-docx in research or writing:
@software{paper_docx,
title = {paper-docx: an agent-first structure editor for Word documents},
author = {{Paper Instruments, Inc.}},
year = {2026},
url = {https://github.com/paper-instruments/paper-docx}
}
Cite it as a fork of python-docx by Steve Canny and contributors.
MIT, inherited from python-docx. Original work © Steve Canny and the python-docx contributors; fork additions © Paper Instruments, Inc. See LICENSE.
Python
96.7%
Gherkin
3.2%