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

@ -14,26 +14,28 @@
function generate() {
const doc = new docx.Document();
doc.addSection({
children: [
new docx.Paragraph({
const doc = new Document({
sections: [
{
children: [
new docx.TextRun("Hello World"),
new docx.TextRun({
text: "Foo Bar",
bold: true,
}),
new docx.TextRun({
text: "\tGithub is the best",
bold: true,
new docx.Paragraph({
children: [
new docx.TextRun("Hello World"),
new docx.TextRun({
text: "Foo Bar",
bold: true,
}),
new docx.TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
}),
},
],
});
docx.Packer.toBlob(doc).then((blob) => {
console.log(blob);
saveAs(blob, "example.docx");