Skip to main content

A specification-driven, pure-Python Word binary .doc to .docx converter

Project description

doc2docx

doc2docx is a pure-Python converter from Microsoft Word 97–2003 binary .doc files to modern .docx files. The conversion engine follows the published Microsoft Office binary-format specifications and does not invoke Microsoft Word, LibreOffice, COM, Java, or another conversion executable.

The project is usable for a growing set of real documents, but it is not yet a complete implementation of every legacy Word feature. Unsupported or lossy content is reported explicitly instead of being silently presented as a fully faithful conversion.

Highlights

  • Reads CFB/OLE Word documents with deterministic, bounded parsers.
  • Preserves text, common character and paragraph formatting, fonts, styles, native numbered and bulleted lists, tables, page layout, sections, headers, and footers.
  • Converts footnotes, endnotes, comments, common date/metadata/page/statistic fields, and positioned textboxes to native WordprocessingML structures.
  • Preserves core document metadata such as title, author, subject, keywords, revision, and creation/modification dates.
  • Restores inline and floating PNG, JPEG, BMP/DIB, TIFF, EMF, and WMF pictures in the main document and header/footer stories.
  • Produces a structured diagnostic report for unsupported, repaired, or approximated source features.
  • Writes deterministic OPC packages using only the Python standard library at runtime.

Installation

python -m pip install msdoc2docx

Python 3.11 or newer is required.

Command line

Convert beside the input file:

doc2docx input.doc

Choose the output path and save a JSON report:

doc2docx input.doc -o output.docx --report report.json

Inspect a source file without converting it:

doc2docx inspect input.doc --json

Python API

from doc2docx import convert

result = convert("input.doc", "output.docx")
print(result.report.to_dict())

The source document is opened read-only. The destination is written through a temporary file and atomically replaced after package validation; the converter will not overwrite the input file.

Current limitations

Password-protected documents are rejected. Embedded OLE objects, Macintosh PICT images, advanced drawing effects, non-rectangular wrap polygons, rare list continuation cases, conditional table styles, uncommon secondary stories, and many specialized fields remain incomplete. Fields that can execute actions or access external content are deliberately kept as cached text. Some legacy layout behavior can only be approximated in WordprocessingML and is called out in the conversion report.

See CHANGELOG.md for milestone and release details.

Development

Run the standard-library test suite from a source checkout:

PYTHONPATH=src python -m unittest discover -v

Build distributable artifacts with:

python -m build

Real-document regression tests may use LibreOffice to create or render test artifacts, but LibreOffice is not used by the converter itself.

Specifications

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

msdoc2docx-0.24.0.tar.gz (126.8 kB view details)

Uploaded Source

Built Distribution

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

msdoc2docx-0.24.0-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

Details for the file msdoc2docx-0.24.0.tar.gz.

File metadata

  • Download URL: msdoc2docx-0.24.0.tar.gz
  • Upload date:
  • Size: 126.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for msdoc2docx-0.24.0.tar.gz
Algorithm Hash digest
SHA256 771f9b912d65f572cf23ec155e2ac0a4b98cf8e31c8e659118c36b5d9bfae6dd
MD5 601d06a9a10d063cc443f2ede242a7bf
BLAKE2b-256 0389a94a29192e6ca1e6638228e880ce68e01ad47c8d4aba628c3c6e7f382ce1

See more details on using hashes here.

File details

Details for the file msdoc2docx-0.24.0-py3-none-any.whl.

File metadata

  • Download URL: msdoc2docx-0.24.0-py3-none-any.whl
  • Upload date:
  • Size: 113.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for msdoc2docx-0.24.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73d80927eee6593fe737ac6b0951a1b7e40835b89eda0bad2d402684b570e976
MD5 b133e82355224ce9cf62303c5dc67956
BLAKE2b-256 cb072c1c39edb1cb388401977d6702d10c4d5de8e6aa857584ce4e42e44cd752

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