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

@ -3,44 +3,46 @@
import * as fs from "fs";
import { Document, Footer, Header, ImageRun, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
},
footers: {
default: new Footer({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
],
}),
},
children: [new Paragraph("Hello World")],
},
children: [new Paragraph("Hello World")],
},
],
});
Packer.toBuffer(doc).then((buffer) => {