- 1. How to read this guide
- 2. The 60-second tour
- 3. Master mapping: Word UI → uniword
- 4. File tab
- 5. Home tab
- 6. Insert tab
- 7. Layout tab
- 8. Design tab
- 9. References tab
- 10. Review tab
- 11. Developer tab
- 12. Things uniword does that Word cannot
- 13. Unmodelled parts: byte-for-byte preservation
- 14. Round-trip and verification
- 15. Building documents programmatically
- 16. Where to go next
Microsoft Word is a GUI application. Uniword is the same feature set, scripted: every Ribbon tab, dialog, and pane that produces or inspects document content has a CLI command or Ruby method equivalent. This page is the master map — use it as both a tutorial (what can uniword do?) and a reference (how do I do X?).
If you have ever wished you could script Word’s UI without COM automation, without a headless LibreOffice, and without clicking the same dialog 200 times, this is the page for you.
1. How to read this guide
Each Word feature is mapped to:
-
a CLI command — for one-shot operations, scripts, and CI
-
a Ruby API call — for embedding inside applications
The two interfaces share the same model layer. Anything you can do in Word’s UI, you can do from either one. Anything Word’s UI cannot do (batch operations, deterministic output, XSD-level verification, repair-and-report), uniword can also do — see Things uniword does that Word cannot.
2. The 60-second tour
A document that exercises almost every Word feature, end to end:
# 1. Convert HTML → DOCX (File → Open)
uniword convert brief.html brief.docx
# 2. Apply a bundled theme (Design → Themes)
uniword theme apply brief.docx themed.docx --name meridian
# 3. Apply a corporate StyleSet (Design → Style Set gallery)
uniword styleset apply themed.docx styled.docx --name signature
# 4. Swap Calibri for Carlito (Home → Replace Fonts)
uniword fonts replace styled.docx defonted.docx --from Calibri --to Carlito
# 5. A4 portrait with 2 cm margins (Layout → Page Setup)
uniword page setup defonted.docx paged.docx --size a4 --margins 2cm
# 6. Insert a TOC (References → Table of Contents)
uniword toc insert paged.docx
# 7. Add a "DRAFT" watermark (Design → Watermark)
uniword watermark add paged.docx "DRAFT"
# 8. Add a footer with the page number (Insert → Footer)
uniword headers add-footer paged.docx "Page "
# 9. Spell-check before sending (Review → Spelling & Grammar)
uniword spellcheck check paged.docx
# 10. Lock for tracked changes (Review → Restrict Editing)
uniword protect apply paged.docx --mode tracked_changes
# 11. Verify the package is OPC-compliant (File → Info → Check Issues)
uniword verify final.docx --xsd
Every step is one command. The same workflow in Word would be eleven click-through dialogs and a lot of repetitive pointing.
3. Master mapping: Word UI → uniword
| Word location | CLI | Ruby API |
|---|---|---|
File → New from template |
|
|
File → Open (any format) |
|
|
File → Info → Check for Issues |
|
|
File → Inspect Document |
|
|
Home → Font (Bold, Italic, Size, Face) |
n/a (build-time) |
|
Home → Paragraph (Alignment, Spacing, Indent) |
n/a (build-time) |
|
Home → Styles pane (list, rename, remove) |
|
|
Home → Replace → Replace Fonts |
|
|
Insert → Table |
n/a (build-time) |
|
Insert → Pictures |
|
|
Insert → Header & Footer |
|
|
Insert → Text Box |
n/a (build-time) |
|
Insert → Links → Bookmark |
n/a (build-time) |
|
Insert → Equation |
n/a (build-time) |
|
Insert → Comment |
n/a (build-time) |
|
Layout → Page Setup (Margins, Size, Orientation) |
|
|
Design → Themes |
|
|
Design → Colors gallery |
|
|
Design → Fonts gallery |
|
|
Design → Watermark |
|
|
References → Table of Contents |
|
|
References → Insert Footnote |
n/a (build-time) |
|
References → Insert Endnote |
n/a (build-time) |
|
Review → Spelling & Grammar |
|
|
Review → Compare (documents) |
|
|
Review → Compare (packages) |
|
|
Review → Comments pane |
|
|
Review → Track Changes (accept/reject) |
|
|
Review → Restrict Editing |
|
|
Developer → Content Controls (SDT) |
n/a (build-time) |
|
File → Save As (DOCX ↔ MHTML) |
|
|
4. File tab
4.1. File → New from template — uniword build
Fill a .docx template with data from YAML or JSON. Markers in the template
are replaced with values, producing a finished document.
uniword build report.docx out.docx --data values.yml
uniword build report.docx out.docx --set title="Q3 Report" --set author="Alice"
4.2. File → Open / Save As (any format) — uniword convert
Convert between DOCX, MHTML (Word 2003), and HTML. Format is auto-detected
from the file extension or --from / --to.
uniword convert brief.docx brief.mhtml
uniword convert brief.html brief.docx
4.3. File → Info → Check for Issues — uniword verify
The full three-layer pipeline: OPC package, XSD schema, and semantic
rules. The --xsd flag enables schema-level validation; otherwise the
XSD layer is skipped.
uniword verify final.docx --xsd --verbose
uniword verify final.docx --json # machine-readable
5. Home tab
5.1. Home → Replace Fonts — uniword fonts replace
Replace one font family throughout the document — body content, styles and defaults, headers/footers, footnotes, endnotes, comments, and numbering definitions. This is Word’s Replace Fonts dialog as a one-shot command.
uniword fonts replace in.docx out.docx --from Calibri --to Carlito
5.2. Home → Styles pane — uniword styles
List every style in a document, rename a style, or remove styles (one by id or all unused). The CLI equivalent of Word’s Styles pane.
# List
uniword styles list report.docx --type paragraph --verbose
# Rename -- references stay linked via styleId
uniword styles rename in.docx out.docx --id Heading1 --name "Chapter Title"
# Remove one
uniword styles remove in.docx out.docx --id ObsoleteStyle
# Clean every unreferenced style
uniword styles remove in.docx out.docx --unused
5.3. Home → Font and Paragraph dialogs — Builder API
There is no CLI for build-time font and paragraph formatting because these are properties of the document you are constructing, not operations on an existing one. Use the Builder API:
Uniword::Builder.new
.add_heading("Chapter 1", level: 1)
.add_paragraph("Important note", bold: true, italic: true, font_size: 24)
.add_paragraph("Right-aligned paragraph", align: :right)
.add_paragraph("Indented", indent: { left: 720 })
.build
See Text Formatting and Paragraph Formatting for the full attribute reference.
6. Insert tab
6.1. Insert → Pictures — uniword images
List, extract, insert, or remove images.
uniword images list report.docx
uniword images extract report.docx /tmp/imgs
uniword images insert report.docx photo.png
uniword images remove report.docx image1.png
6.2. Insert → Header & Footer — uniword headers
Add a header or footer, list what’s there, or remove them.
uniword headers list report.docx
uniword headers add-header report.docx "Company Confidential"
uniword headers add-footer report.docx "Page "
uniword headers remove report.docx
6.3. Insert → Equation — Builder API
OMML (Office Math Markup Language) equations are first-class content via
the Math guide. The omml gem handles round-trip,
and Builder#add_math accepts LaTeX input:
builder.add_math(latex: "E = mc^2")
builder.add_math(latex: "\\frac{a}{b} = c")
6.4. Insert → Comment — Builder API
Comments are anchored to a paragraph with Builder#comment. The anchored
paragraph gets commentRangeStart / commentRangeEnd plus a
commentReference run; the comment itself lives in word/comments.xml,
which round-trips through load/save.
builder.add_paragraph("Controversial claim").comment(
text: "Citation needed",
author: "QA",
on: :paragraph
)
6.5. Insert → Text Box, Bookmark, Hyperlink — Builder API
All three are first-class content during document construction. See Text Boxes and Bookmarks and References.
builder.add_text_box("Pull quote", width: "3in", height: "1in")
builder.bookmark("sec-methods")
builder.hyperlink("Read more", url: "https://example.com")
7. Layout tab
8. Design tab
8.1. Design → Themes — uniword theme apply
Apply a theme (colors, fonts, and formats together) from the
29 bundled themes, an imported YAML, or a
.thmx file.
uniword theme apply in.docx out.docx --name meridian
uniword theme apply in.docx out.docx --name atlas --variant 2
8.2. Design → Colors / Fonts galleries — uniword theme colors / fonts
Replace just the color scheme or just the font scheme, keeping everything else. These are the Design tab’s Colors and Fonts dropdowns as one-shot commands.
uniword theme colors in.docx out.docx --name emerald
uniword theme fonts in.docx out.docx --name carlito_sans
uniword theme colors --list # list available schemes
8.3. Design → Style Set gallery — uniword styleset apply
Apply a StyleSet (paragraph, character, and table style definitions) from the 12 bundled StyleSets or an imported YAML.
uniword styleset apply in.docx out.docx --name signature
uniword styleset apply in.docx out.docx --name ceremonial --strategy replace
styleset extract captures an existing document’s styles into a YAML
StyleSet you can re-apply elsewhere.
uniword styleset extract corporate_report.docx
9. References tab
9.1. References → Table of Contents — uniword toc
Generate TOC entries from headings, insert a TOC into the document, or update an existing one.
uniword toc generate report.docx
uniword toc insert report.docx
uniword toc update report.docx
|
To make Word rebuild the TOC and other fields when the document is opened,
save with
|
9.2. References → Footnotes / Endnotes — Builder API
Footnotes and endnotes are first-class content during construction. The
Reconciler keeps footnotePr / footnotes.xml in sync, and round-trip
preserves everything. See Footnotes and
Endnotes.
10. Review tab
10.2. Review → Compare — uniword diff
Document-level diff (content, formatting, structure, metadata, styles) or package-level diff (ZIP parts, XML content, OPC validation).
uniword diff compare old.docx new.docx
uniword diff package old.docx new.docx
10.3. Review → Comments — uniword review comments
List every comment with its author, date, and text.
uniword review comments report.docx
10.4. Review → Track Changes — uniword review accept/reject
Accept or reject individual revisions or all at once.
uniword review changes report.docx # list
uniword review accept report.docx 42 # one revision
uniword review reject report.docx 42
uniword review accept-all report.docx
uniword review reject-all report.docx
11. Developer tab
11.1. Developer → Content Controls (Structured Document Tags)
SDTs are first-class content during construction. See Structured Document Tags.
builder.content_control(type: :rich_text, tag: "title", placeholder: "Enter title")
11.2. Developer → Macros (VBA)
Documents with VBA projects (.docm) round-trip byte-for-byte: the VBA
part is preserved as a Docx::RawPart and re-emitted verbatim on save.
This applies to every part uniword does not model — glossary documents,
docProps/meta.xml, custom XML outside the standard layout, header/comment
.rels sidecars. See Unmodelled parts: byte-for-byte preservation below.
12. Things uniword does that Word cannot
These are the things you would never get from the Word UI — they are why uniword exists.
| Capability | What it gives you |
|---|---|
Scriptable from the command line |
One-shot conversions, repairs, and transforms. No COM, no headless Office, no clicking. |
Deterministic output |
|
Three-layer verification |
|
Write-time integrity gate |
|
Reconciler with reporting |
|
Round-trip fidelity |
100% preservation of all 760 OOXML elements across 22 namespaces. ISO documents round-trip with 0 normative differences. |
Raw parts preservation |
Anything uniword does not model (VBA, glossary, custom XML) is preserved byte-for-byte instead of dropped. |
Batch processing |
|
Server-side execution |
No GUI dependency. Runs on Linux servers, CI runners, Docker containers. |
Open-source resources |
29 OFL themes, 12 OFL StyleSets, 23 color schemes, 25 font schemes — no proprietary Microsoft assets bundled. |
Profile-driven output |
Profiles tune output to a specific Word version, locale, and user identity. |
13. Unmodelled parts: byte-for-byte preservation
Uniword models 760 OOXML elements across 22 namespaces. Some real-world documents carry parts that are not (yet) modelled:
-
VBA projects (
vbaProject.bin,.docm) -
Glossary documents (
word/glossary/document.xml) -
docProps/meta.xmland other custom property parts -
customXml/items outside the standard layout -
Header and comment
.relssidecars
Older versions of uniword silently dropped these on load, which broke
round-trip fidelity for documents that used them. As of 1.4.0, every part
the library does not model is preserved as a Docx::RawPart with its
source content type, and re-emitted verbatim on save. The reconciler keeps
relationships targeting them; the write-time integrity gate treats them
as first-class parts.
This means:
-
.docmfiles round-trip without losing their macros -
documents with embedded PDFs, OLE objects, or custom XML survive load-modify-save cycles unchanged
-
nothing about the original package is silently lost
14. Round-trip and verification
Two pages complement this guide:
-
Round-Trip Fidelity — what is preserved and how it’s tested (ISO 8601, ISO 690, ISO DIS 5878).
-
Three-Layer Verification — the OPC / XSD / semantic pipeline behind
uniword verify.
15. Building documents programmatically
The Builder API is the programmatic equivalent of this guide: a fluent interface for constructing documents with rich formatting, tables, lists, images, math, bookmarks, comments, hyperlinks, and content controls.
doc = Uniword::Builder.new
.add_heading("Quarterly Report", level: 1)
.add_paragraph("Prepared by Finance", italic: true)
.add_paragraph("This document is DRAFT.", bold: true)
.comment(text: "Remove before sending", author: "QA", on: :paragraph)
.add_heading("Methodology", level: 2)
.bookmark("sec-methods")
.add_paragraph("Revenue is computed as...")
.add_math(latex: "\\text{revenue} = \\sum_{i=1}^{n} p_i \\cdot q_i")
.add_table do
row do
cell "Quarter", bold: true
cell "Revenue", bold: true
end
row do
cell "Q1"
cell "$1.2M"
end
end
.build
doc.apply_theme("meridian")
doc.apply_styleset("signature")
doc.add_header("Acme Inc. — Confidential")
doc.add_footer("Page ")
doc.add_watermark("DRAFT", color: "#888888")
doc.protect(:comments)
doc.save("report.docx")
That single block replaces a long Word session: write the body, apply a theme and StyleSet, add a header and footer, watermark, lock for comments-only edits, and save.
16. Where to go next
-
Quick Start — five-minute intro
-
Builder API — fluent document construction
-
Round-Trip Fidelity — guarantees and tests
-
Three-Layer Verification — the verification pipeline