* Turn patch document into options object Add outputType to options * Set keep styles to true by default * Simplify method * Rename variable * #2267 Multiple patches of same key * Remove path which won't be visited
18 lines
432 B
TypeScript
18 lines
432 B
TypeScript
// Patch a document with patches
|
|
|
|
import * as fs from "fs";
|
|
import { patchDocument, PatchType, TextRun } from "docx";
|
|
|
|
patchDocument({
|
|
outputType: "nodebuffer",
|
|
data: fs.readFileSync("demo/assets/simple-template-2.docx"),
|
|
patches: {
|
|
name: {
|
|
type: PatchType.PARAGRAPH,
|
|
children: [new TextRun("Max")],
|
|
},
|
|
},
|
|
}).then((doc) => {
|
|
fs.writeFileSync("My Document.docx", doc);
|
|
});
|