Skip to main content

Pure-Python text extraction for classic Microsoft Word .doc files.

Project description

legacy-doc

legacy-doc is a small, dependency-free Python library for extracting readable text from classic Microsoft Word .doc files.

It is intentionally narrow:

  • supports OLE Compound File Word 97-2003 .doc files
  • extracts normalized text from the Word piece table
  • rejects encrypted, malformed, non-OLE, or unsafe files clearly
  • does not execute macros, embedded objects, links, scripts, or external references
  • does not use native binaries, LibreOffice, antiword, or third-party parsers

Install

pip install legacy-doc

Usage

from legacy_doc import extract_text

with open("document.doc", "rb") as file:
    result = extract_text(file.read())

print(result.text)
print(result.metadata)

API

extract_text(document_bytes: bytes, *, options: ExtractionOptions | None = None) -> DocExtractionResult

DocExtractionResult contains:

  • text: normalized extracted text
  • parser: parser name
  • version: parser version
  • metadata: lightweight extraction metadata
  • warnings: non-fatal parser warnings

Limitations

This is not a full Microsoft Word renderer. It aims to recover readable text safely from common legacy .doc files. Formatting fidelity, OCR, images, macros, tracked changes, and embedded object extraction are out of scope.

Development

python -m pip install -e ".[dev]"
python -m pytest
python -m build
python -m twine check dist/*

The test suite includes small generated OLE WordDocument fixtures and malformed corpus cases for parser limits, encryption markers, missing piece tables, and cyclic FAT chains.

Security

legacy-doc treats input files as untrusted binary data. It performs bounded parsing, rejects encrypted documents, and never executes macros or embedded content. Report security issues privately before opening a public issue.

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

legacy_doc-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

legacy_doc-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file legacy_doc-0.1.0.tar.gz.

File metadata

  • Download URL: legacy_doc-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for legacy_doc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9fe42eab26059f7692d1142baf4b366437500b07779ed06173e4698d2d309ae
MD5 477925abb5e9c568bf53697e34e61154
BLAKE2b-256 368065a1204e91c370185d3df27e33647945c5254ac6d6107a81879962e2de1d

See more details on using hashes here.

File details

Details for the file legacy_doc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: legacy_doc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for legacy_doc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e1828dd36cb4739885fda6c9d741d979c1d40c467316232d878267281acd218
MD5 abc07a54be2ce785989852cdfdd4b990
BLAKE2b-256 54fb9d3b4a3a4ad7ced3c2e799621f9c0939a2914d4f83cd6c67d026756f4928

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