Files
docx-js/demo/87-template-document.ts

18 lines
432 B
TypeScript
Raw Normal View History

2023-03-23 21:01:24 +00:00
// Patch a document with patches
2023-06-05 00:33:43 +01:00
2023-03-23 21:01:24 +00:00
import * as fs from "fs";
2023-06-05 00:33:43 +01:00
import { patchDocument, PatchType, TextRun } from "docx";
2023-03-23 21:01:24 +00:00
patchDocument({
outputType: "nodebuffer",
data: fs.readFileSync("demo/assets/simple-template-2.docx"),
2023-03-23 21:01:24 +00:00
patches: {
name: {
type: PatchType.PARAGRAPH,
children: [new TextRun("Max")],
},
},
}).then((doc) => {
fs.writeFileSync("My Document.docx", doc);
});