Files
docx-js/demo/85-template-document.ts
2023-02-18 20:36:24 +00:00

16 lines
437 B
TypeScript

// Simple template example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { patchDocument, TextRun } from "../build";
patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
patches: [
{
children: [new TextRun("John Doe")],
text: "{{ name }}",
},
],
}).then((doc) => {
fs.writeFileSync("My Document.docx", doc);
});