A Word document or template (.docx, .docm, .dotx or .dotm), a PowerPoint presentation (.pptx), an Excel workbook (.xlsx), an Office theme (.thmx), or the XML of a theme, such as a document's word/theme/theme1.xml, or of a theme's colors or fonts, as text or bytes
The theme's options, to give Document's theme, or to change before giving it
import * as fs from "fs";
import { Document, readTheme } from "docx";
// The template's styles, and its theme, whose colors and fonts its styles use
const doc = new Document({
theme: readTheme(fs.readFileSync("template.dotx")),
externalStyles: fs.readFileSync("styles.xml", "utf-8"),
sections: [],
});
Reads a theme, such as the theme of a Word document or template, as the options of a document's
theme. The new document then has the theme's colors and fonts, so the styles, tables and text that use them look as they do in the file the theme came from:The fills, lines and effects of shapes styled by the theme are Office's in the new document, as
docxwrites them.It reads the colors or fonts Word saves on their own too, from Design > Colors > Customize Colors or Design > Fonts > Customize Fonts, as the theme's
colorsorfonts.