Compose .docx documents
Project description
docxcompose is a Python library for concatenating/appending Microsoft Word (.docx) files.
Example usage
Append a document to another document:
from docxcompose.composer import Composer
from docx import Document
master = Document("master.docx")
composer = Composer(master)
doc1 = Document("doc1.docx")
composer.append(doc1)
composer.save("combined.docx")
The docxcompose console script
The docxcompose console script allows to compose docx files from the command line, e.g.:
$ docxcompose files/master.docx files/content.docx -o files/composed.docx
Installation for development
To install docxcompose for development, clone the repository and using a python with poetry:
$ poetry install
Tests can then be run with pytest.
A note about testing
The tests provide helpers for blackbox testing that can compare whole word files. To do so the following files should be provided:
a file for the expected output that should be added to the folder docs/composed_fixture
multiple files that can be composed into the file above should be added to the folder docs.
The expected output can now be tested as follows:
def test_example():
fixture = FixtureDocument("expected.docx")
composed = ComposedDocument("master.docx", "slave1.docx", "slave2.docx")
assert fixture == composed
Should the assertion fail the output file will be stored in the folder docs/composed_debug with the filename of the fixture file, expected.docx in case of this example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docxcompose-2.0.1.tar.gz.
File metadata
- Download URL: docxcompose-2.0.1.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.13.7 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
649ba37655985c093159fe899a519eee5e31bc64344610ac1a1e2d719ec41d2a
|
|
| MD5 |
90d54add0f6ca9e4be328a27bdecd12b
|
|
| BLAKE2b-256 |
d143e506b12f7e7f8629cedc04ffe7f75b3e97e278a0557c1153cfd2f7671c56
|
File details
Details for the file docxcompose-2.0.1-py3-none-any.whl.
File metadata
- Download URL: docxcompose-2.0.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.13.7 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b77b265ba9a7d53b4932d92c0ca116839b3d57eeea97c39c8da1ba90e9af810
|
|
| MD5 |
70b278f4ec9ac11147bd7072079e91c3
|
|
| BLAKE2b-256 |
8ead4c07f0da82b5c3a3d2666c7a334418fb8425b54e5eef4f3abc2eb2951457
|