Files
docx-js/demo/86-generate-template.ts
2023-06-05 00:33:43 +01:00

21 lines
443 B
TypeScript

// Generate a template document
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [new TextRun("{{template}}")],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});