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.post1.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.post1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docxcompose_tes-1.4.1.post1.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.post1.tar.gz
Algorithm Hash digest
SHA256 910d8aa37d98bee885612383c4c8440ae151e3499be9f8a132895e1e562ab208
MD5 6a919a659435335a5bc2fdec076ffe4d
BLAKE2b-256 86e5d6c0199716eadf3b702b1bc9548eb7c2e39c24623013cec3514c1ebbdce9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for docxcompose_tes-1.4.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5a6995a0e22f616b138fe776fb5547b3662393bec317797a8f9d854235ecb0d
MD5 bfc92fc4dedd95845f891e0b22ba64ab
BLAKE2b-256 24aa60025ce3cf34f98b4a7f0b554f19957c12a5b993e910a77b3d7661e517e9

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