Skip to main content

Python library for concatenating/appending Microsoft Word (.docx) files.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

docxcompose is a Python library for concatenating/appending Microsoft Word (.docx) files.

This fork fixes the DeprecationWarning on pkg_import, and modernizes the build system.

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 setuptools (for example a fresh virtualenv), install it using pip:

$ pip install -e .[tests]

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.

Headers and footers

The first document is considered as the main template and headers and footers from the other documents are ignored, so that the header and footer of the first document is used throughout the merged file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docxcompose_tes-1.4.1.post0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docxcompose_tes-1.4.1.post0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file docxcompose_tes-1.4.1.post0.tar.gz.

File metadata

  • Download URL: docxcompose_tes-1.4.1.post0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for docxcompose_tes-1.4.1.post0.tar.gz
Algorithm Hash digest
SHA256 3d8af38b26d288422c73f88d2bfa458cb6e85c0b33f88119b0bb74c17937bb91
MD5 fed1185c3cc96a0722fbe7ce39148b4c
BLAKE2b-256 41d39a4884247d6130cd25cbe1369fbead8afb3d60b6baafd152899a35edfd52

See more details on using hashes here.

File details

Details for the file docxcompose_tes-1.4.1.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for docxcompose_tes-1.4.1.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9091ac170b9720f83125dbdc713aac3fd9c6cf59cabac9c3ee76d614cb396f
MD5 911f4b85e95459a61463f5d60fe4d5e8
BLAKE2b-256 eed82e8cfc02928e7e87b68e1a7e296859f968fe558d890d18e17f69e193271b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page