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

@ -37,20 +37,14 @@ const image = new ImageRun({
Add it into the document by adding the image into a paragraph:
```ts
doc.addSection({
children: [new Paragraph(image)],
});
```
Or:
```ts
doc.addSection({
children: [
new Paragraph({
children: [image],
}),
],
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [image],
}),
],
}];
});
```
@ -59,16 +53,22 @@ doc.addSection({
Adding images can be easily done by creating an instance of `ImageRun`. This can be added in a `Paragraph` or `Hyperlink`:
```ts
const image = new ImageRun({
data: [IMAGE_BUFFER],
transformation: {
width: [IMAGE_SIZE],
height: [IMAGE_SIZE],
},
});
doc.addSection({
children: [new Paragraph(image)],
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [
new ImageRun({
data: [IMAGE_BUFFER],
transformation: {
width: [IMAGE_SIZE],
height: [IMAGE_SIZE],
},
}),
],
}),
],
}];
});
```