A drop-in replacement for Microsoft Word, for the agentic era.
Live demo (f-office.org/docs) · CLI · Rust · JavaScript / Browser · Roadmap
F-Office is a Rust layout, rendering, and editing engine for DOCX documents, built for AI agents and applications that need every page to break the way Microsoft Word breaks it.
In contracts, filings, and reports, pagination is part of the document. People notice where a page ends, how a table splits across pages, and which line a signature lands on, so an edit that shifts a page break can spoil a document even when every word is right. F-Office closes that loop. An agent or program can inspect paragraphs and tables by stable address, apply atomic edit lists that either land in full or leave the file untouched, see exactly which pages moved, and render full pages or cropped diffs to PNG or PDF before handing the file back.
Microsoft Word lays out documents using Windows and Office fonts that are absent on Linux servers, containers, and browsers. The foffice CLI bundles metric-compatible open fonts from Compatifont (OFL-1.1) so lines break at the same word on any machine, with no copy of Word and no Windows host. The same engine compiles to WebAssembly (@f-office/core) for browser and Node.js apps, using lazy ZIP reading, progressive Page-1-first , and tiled rendering to stay within mobile memory budgets, alongside the drop-in F-Office Docs (F-Docs) browser component (@f-office/docs) and React 19 UI (@f-office/docs-react).
Currently supports F-Office Docs (Word for Windows word-win DOCX files), with F-Office Sheets (@f-office/sheets, XLSX) and F-Office Slides (@f-office/slides, PPTX) planned next. The F stands for Free. Any other reading is on you.
From crates.io:
cargo install f-office-cli
Or pre-built binaries with cargo-binstall (or from GitHub Releases):
cargo binstall f-office-cli
foffice convert report.docx --to pdf --out out/report.pdf
foffice convert report.docx --to png --pages 1-3 --dpi 150 --outdir pages
foffice read report.docx
foffice read report.docx --at t1 --format json
foffice edit report.docx edits.json --out report-v2.docx
foffice diff report.docx report-v2.docx --outdir diff
foffice skill --outdir .agents/skills
By default, foffice bundles open metric-compatible fonts from Compatifont (OFL-1.1) covering Arial, Arial Narrow, Arial Black, Times New Roman, Calibri, Cambria, Cambria Math, Aptos, Aptos Display, Courier New, Georgia, Segoe UI, Comic Sans MS, and the Office symbol fonts when those fonts are not installed on your system.
The library itself does not ship fonts. Pass your own font files or open metric-compatible fonts from Compatifont.
Add f-office to your Cargo.toml:
[dependencies]
f-office = "0.2"
use f_office::{Document, FontDatabase, Options};
fn convert_to_pdf(docx: &[u8], font_bytes: &[u8]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
let mut fonts = FontDatabase::new();
fonts.add_font(font_bytes)?;
let opened = Document::open(docx, &fonts, &Options::default())?;
for (index, page) in opened.value.pages().iter().enumerate() {
let width_pt = page.width().units() as f64 / f_office::Length::UNITS_PER_POINT as f64;
let height_pt = page.height().units() as f64 / f_office::Length::UNITS_PER_POINT as f64;
println!("page {}: {:.1} x {:.1} pt", index + 1, width_pt, height_pt);
}
let pdf = opened.value.write_pdf(&fonts)?;
Ok(pdf.value)
}
Headless engine (browser and Node.js):
npm install @f-office/core
js
import { init, Renderer, loadFontsFor } from "@f-office/core";
await init();
const renderer = new Renderer();
// Load fonts required by the document (e.g., from @compatifont/fonts or your own CDN)
await loadFontsFor(renderer, docxBytes, async (family) => fetchFontFamily(family));
using doc = renderer.openDocx(docxBytes, { target: "word-win" });
using page = doc.renderPage(0, 96 * devicePixelRatio);
ctx.putImageData(page.toImageData(), 0, 0);
// Or export directly to PDF
const pdfBytes = doc.writePdf();
Drop-in F-Office Docs browser component (<f-office-docs> / FOfficeDocs, zero framework):
npm install @f-office/docs @f-office/core
React 19 Google Docs–style UI (<DocsApp />, <DocsProvider>, <FOfficeDocs />):
npm install @f-office/docs-react @f-office/docs @f-office/core react react-dom
See packages/core/README.md for the headless WASM engine and Web Worker API, packages/docs/README.md for the framework-free <f-office-docs> Web Component, and packages/docs-react/README.md for the React 19 components and composable Docs UI.
F-Office is early work (0.x), and its public API may evolve before 1.0.
| # | Milestone | Status |
|---|---|---|
| 1 | Text, lists, tables, sections, columns, headers, footers, footnotes, and fields | ✅ |
| 2 | Pixel output, PDF export, CLI ( foffice ), and JS/WASM engine (@f-office/core ) |
✅ |
| 3 | Floating pictures, text boxes, shapes, and text wrapping | ✅ |
| 4 | Charts (column, bar, line, pie, doughnut, scatter, combo) | |
| 5 | Comments and tracked changes | |
| 6 | East Asian text layout | |
| 7 | Drop-in <f-office-docs> Web Component (@f-office/docs ) |
✅ |
| 8 | Other suite products (F-Office Sheets / XLSX, F-Office Slides / PPTX) | ❌ |
Licensed under the MIT License. See NOTICE for third-party attributions.
Microsoft, Office, Word, Excel and PowerPoint are trademarks of Microsoft. F-Office is not affiliated with Microsoft.