21 lines
517 B
TypeScript
21 lines
517 B
TypeScript
![]() |
// 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({
|
||
|
children: [new TextRun("{{ template }}")],
|
||
|
}),
|
||
|
],
|
||
|
},
|
||
|
],
|
||
|
});
|
||
|
|
||
|
Packer.toBuffer(doc).then((buffer) => {
|
||
|
fs.writeFileSync("My Document.docx", buffer);
|
||
|
});
|