Make .addSection fully declarative

This commit is contained in:
Dolan
2021-03-19 20:53:56 +00:00
parent 4783812044
commit 3299c557a0
86 changed files with 3341 additions and 3278 deletions

View File

@ -12,16 +12,21 @@ fs.readFile(filePath, (err, data) => {
}
importDotx.extract(data).then((templateDocument) => {
const doc = new Document(undefined, {
template: templateDocument,
});
doc.addSection({
properties: {
titlePage: templateDocument.titlePageIsDefined,
const doc = new Document(
{
sections: [
{
properties: {
titlePage: templateDocument.titlePageIsDefined,
},
children: [new Paragraph("Hello World")],
},
],
},
children: [new Paragraph("Hello World")],
});
{
template: templateDocument,
},
);
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);