Project

uniword

0.0
No release in over 3 years
Comprehensive Ruby library for creating and manipulating Microsoft Word documents in DOCX and MHTML formats. Features include full formatting support, tables, lists, images, headers/footers, styles, and bidirectional format conversion.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 2.8
~> 1.18
~> 2.3
~> 1.3
 Project Readme

Uniword

Gem Version License Build Status

Uniword is a Ruby library for reading and writing Microsoft Word documents in DOCX (Word 2007+) and MHTML (Word 2003+) formats, with 100% OOXML specification coverage (760 elements, 22 namespaces) and perfect round-trip fidelity.

Installation

Add to your Gemfile:

gem 'uniword'

Or install directly:

gem install uniword

Quick Start

require 'uniword'

# Create a document
doc = Uniword::Builder.new
  .add_heading('My Document', level: 1)
  .add_paragraph('Hello World', bold: true)
  .build
doc.save('output.docx')

# Read and modify
doc = Uniword::DocumentFactory.from_file('input.docx')
puts doc.text
doc.save('modified.docx')

# Apply theme and styleset
doc = Uniword::Wordprocessingml::DocumentRoot.new
doc.apply_theme('meridian')
doc.apply_styleset('signature')
doc.save('styled.docx')

CLI

uniword convert input.docx output.doc        # DOCX to MHTML
uniword info document.docx                   # Document info
uniword validate document.docx               # Schema validation
uniword verify document.docx                 # Full 3-layer verification
uniword theme apply doc.docx out.docx -n meridian  # Apply theme
uniword theme auto ms.docx uniword.docx      # Auto MS->Uniword transition

Features

  • Full DOCX and MHTML read/write with format conversion

  • 29 bundled themes, 12 stylesets, 23 color schemes, 25 font schemes

  • 30-locale document elements (240 templates)

  • MS font to open-source substitution (Calibri→Carlito, Arial→Liberation Sans)

  • Auto theme transition: detect MS themes by color fingerprint

  • DOCX validation: 3-layer pipeline (OPC + XSD + semantic rules)

  • Prevention layer: auto-fix footnote/endnote cross-part invariants

  • Tables, lists, images, headers/footers, footnotes, bookmarks, math

  • Fluent Builder API and CLI interface

Documentation

Full documentation is at metanorma.github.io/uniword.

Contributing

See CONTRIBUTING.md for development guidelines. Bug reports and pull requests are welcome at https://github.com/metanorma/uniword.

License

The gem is available as open source under the terms of the BSD 2-Clause License.

Copyright (c) 2024 Ribose Inc.