DOC · WORD 97–2003

Legacy Word
API guide

The Word helpers read plain text from the main document body of binary .doc files. The edit API replaces one existing paragraph while carrying over its paragraph and first-run formatting.

IMPLEMENTATION NOTES

What works

Use readOleDocParagraphs to get main-body paragraph strings. writeOleDocParagraphEdit appends replacement text and updates the piece table rather than shifting bytes it does not understand.

IMPLEMENTATION NOTES

Known limits

This is not a general Word parser or renderer. It does not expose tables, headers, footers, footnotes, comments, fields, bookmarks, or rich run structure through this API.

QUICK EXAMPLE

Use the supported API

Import the package root unless a subpath is shown in the sample.

Legacy Word · TypeScript
TypeScript
import { readOleDocParagraphs, writeOleDocParagraphEdit } from '@christophervr/ole2';

const paragraphs = readOleDocParagraphs(docBytes);
if (paragraphs) {
  console.log(paragraphs[0]);
  const edited = writeOleDocParagraphEdit(docBytes, 0, 'Updated paragraph');
  if (edited === docBytes) console.log('Edit was unsupported or unsafe.');
}

This guide documents the current package API. Unsupported or unsafe operations are described explicitly; format detection alone does not imply content support.

Back to format overview