Files
docx-js/demo/86-generate-template.ts

21 lines
515 B
TypeScript
Raw Normal View History

2023-02-25 22:18:31 +00:00
// Generate a template document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document({
sections: [
{
children: [
new Paragraph({
2023-02-25 22:18:56 +00:00
children: [new TextRun("{{template}}")],
2023-02-25 22:18:31 +00:00
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});