2023-02-25 22:18:31 +00:00
|
|
|
// Generate a template document
|
2023-06-05 00:33:43 +01:00
|
|
|
|
2023-02-25 22:18:31 +00:00
|
|
|
import * as fs from "fs";
|
2023-06-05 00:33:43 +01:00
|
|
|
import { Document, Packer, Paragraph, TextRun } from "docx";
|
2023-02-25 22:18:31 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|