Skip to main content

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

Project description

legacy-doc

Downloads

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.1.tar.gz (8.4 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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: legacy_doc-0.1.1.tar.gz
  • Upload date:
  • Size: 8.4 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.1.tar.gz
Algorithm Hash digest
SHA256 86e3e4663eea9f52428a3cf50ec75d826fc25454f20222b53532a83342d90819
MD5 71f934a39a3a884fdbd428aa76004d52
BLAKE2b-256 a60d1a3460a5350c1267d931bdb0350bb572012a2ed3ead039a32a71b5fdb5b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: legacy_doc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c4a6b33e6c83757c5e1589afdee199b97441eb97f7d6c375a728416b5cad3fd
MD5 2557e98f07fcc1d9f3c7d4a4a7d49d9f
BLAKE2b-256 48320043d4752194a62c11f9af5ffe5057bfc967e125dce5872639fdf9820823

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