Skip to main content
OfficeIMO Docs Search documentation/

Word Documents

Edit on GitHub

Overview of the OfficeIMO.Word package for creating and manipulating Microsoft Word documents. Includes examples and API links.

The OfficeIMO.Word package provides a higher-level API for creating, reading, and modifying Microsoft Word documents (.docx) without requiring Microsoft Office. It wraps the Open XML SDK with an approachable object model and adds workflow-oriented capabilities for template binding, review inspection, structural comparison, redlines, content-control forms, package signatures, conversion, legacy DOC import/export, and page rendering.

Choose a workflow

GoalStart here
Compose reports, contracts, and invoicesParagraphs, tables, images, lists, charts, sections, fields, and reusable styles on this page and the focused authoring guides
Use an approved DOCX as the layoutTemplates, forms, and mail merge
Process comments and tracked changesReview, comparison, revisions, and signatures
Publish or exchange the documentWord conversion and rendering
Evaluate a feature against the current implementationMarket readiness and the generated Word API

Key Classes

ClassDescription
WordDocumentThe root class representing a Word document. Provides factory methods for creating and loading documents.
WordSectionRepresents a section within a document. Controls page layout, headers, footers, and contains paragraphs and tables.
WordParagraphRepresents a paragraph with text, formatting, images, hyperlinks, bookmarks, and field codes.
WordTableRepresents a table with rows, cells, and 105+ built-in table styles.
WordImageRepresents an inline or anchored image with sizing, cropping, and positioning controls.
WordHeader / WordFooterHeader and footer instances attached to sections.
WordChartEmbeds bar, line, area, pie, scatter, and radar charts.
WordListManages numbered and bulleted lists with customizable styles.
WordBookmarkRepresents a named bookmark within the document.
WordTableOfContentInserts and manages a table of contents.
WordFluentDocumentFluent builder API for composing documents with chained method calls.

Creating a Document

using OfficeIMO.Word;

// Create and save to a file
using var document = WordDocument.Create("output.docx");

document.AddParagraph("Welcome to OfficeIMO");
document.Save();

To create a document in memory (no file path):

using var document = WordDocument.Create();
document.AddParagraph("In-memory document");

// Save to a stream later
using var stream = new MemoryStream();
document.Save(stream);

Loading an Existing Document

using var document = WordDocument.Load("existing.docx");

// Read all paragraphs
foreach (var paragraph in document.Paragraphs) {
    Console.WriteLine(paragraph.Text);
}

// Modify and save
document.AddParagraph("Appended paragraph");
document.Save();

Document Structure

A WordDocument contains one or more WordSection instances. Each section can have its own page layout (size, orientation, margins), headers, and footers. Sections contain paragraphs, tables, images, and other block-level elements.

WordDocument
  +-- Sections[]
  |     +-- Paragraphs[]
  |     +-- Tables[]
  |     +-- Images[]
  |     +-- Header (Default, First, Even)
  |     +-- Footer (Default, First, Even)
  +-- Paragraphs      (all paragraphs across sections)
  +-- Tables           (all tables across sections)
  +-- Lists            (all list definitions)
  +-- Bookmarks        (all bookmark paragraphs)

Document Properties

using var document = WordDocument.Create("props.docx");

document.BuiltinDocumentProperties.Title = "Quarterly Report";
document.BuiltinDocumentProperties.Creator = "OfficeIMO";
document.BuiltinDocumentProperties.Description = "Q4 2025 financial summary";

document.ApplicationProperties.Company = "Evotec";

document.Save();

Sections

Add a new section to change page layout mid-document:

using var document = WordDocument.Create("sections.docx");

document.AddParagraph("Portrait section content");

// Start a new section in landscape
var section = document.AddSection();
section.PageOrientation = Orientation.Landscape;
section.PageSettings.Width = 15840;
section.PageSettings.Height = 12240;

document.AddParagraph("Landscape section content");

document.Save();

Further Reading

  • Paragraphs — Text formatting, alignment, spacing, and fonts.
  • Tables — Creating, styling, merging, and inspecting tables.
  • Images — Adding images from files, streams, URLs, and base64.
  • Headers and Footers — Page numbers, different first-page headers, and section-specific content.
  • Templates, forms, and mail merge — Preflight and bind layout-owned templates.
  • Review and comparison — Inspect comments and revisions, compare structure, create redlines, and enforce signed-document policy.
  • Conversion and rendering — Choose HTML, Markdown, PDF, OpenDocument, RTF, Google Docs, or image output.
  • Production workflows — Template assembly, conversion, review, proof artifacts, and validation.