This post was flagged by the community and is temporarily hidden.
odf-kit v0.3.0 — Template Engine
v0.3.0 adds a template engine to odf-kit. You can now create a .odt template in LibreOffice with {placeholders} in the text, then fill it with data from JavaScript:
javascript
import { fillTemplate } from "odf-kit";
import { readFileSync, writeFileSync } from "fs";
const template = readFileSync("invoice-template.odt");
const result = fillTemplate(template, {
customer: "Acme Corp",
items: [
{ product: "Widget", qty: 5 },
{ product: "Gadget", qty: 3 },
],
showNotes: true,
notes: "Net 30",
});
writeFileSync("invoice.odt", result);
What it supports:
-
{tag}— simple replacement -
{#tag}...{/tag}— loops (arrays) and conditionals (truthy/falsy) -
{object.property}— dot notation for nested data - Headers and footers with placeholders
- Automatic handling of LibreOffice’s XML fragmentation of placeholder text
The engine is purpose-built for ODF — it understands <text:span> splitting and cleans up editing artifacts like <text:s/> and <text:bookmark/> inside fragmented placeholders.
Zero transitive dependencies. 222 tests. Apache 2.0.
Switched from jszip to fflate.
odf-kit v0.4.0 — Browser Support
odf-kit now works in browsers as well as Node.js. Same API, same output — generate .odt files entirely client-side with no server required. User data never leaves the browser.
Works in Chrome, Firefox, Safari, and Edge. Also Deno, Bun, and Cloudflare Workers. Use any bundler (Vite, webpack, esbuild, Rollup) — just import { OdtDocument } from "odf-kit" and it resolves automatically.
The TypeScript build now enforces cross-platform compatibility at compile time — Node-specific APIs physically cannot exist in the library source code, so browser support is a permanent architectural property, not something that can regress.
Also updated minimum Node.js requirement from 22 to 18.