Table of Contents
Get started with Uniword in under a minute. This page walks through the two most common operations: creating a new document and reading an existing one.
1. Creating documents
require 'uniword'
# Simple document
doc = Uniword::Document.new
para = Uniword::Paragraph.new
para.add_text("Hello World", bold: true)
doc.add_element(para)
doc.save('output.docx')
The resulting output.docx is a valid Word file you can open in Microsoft Word, LibreOffice, or Google Docs.
2. Reading documents
doc = Uniword::DocumentFactory.from_file('input.docx')
# Extract all text
puts doc.text
# Iterate over paragraphs
doc.paragraphs.each { |p| puts p.text }
3. What’s next?
-
Core Concepts — Understand the model-driven architecture.
-
Your First Document — Build a complete document step by step.