Updated documentation

This commit is contained in:
Dolan
2019-08-21 00:05:46 +01:00
parent 535f2d75b0
commit 7827d158d7

View File

@ -2,52 +2,46 @@
!> Headers and Footers requires an understanding of [Sections](usage/sections.md). !> Headers and Footers requires an understanding of [Sections](usage/sections.md).
## Example Every Section has a sections which you can define its Headers and Footers:
Creating Headers and footers is simple. Access the `Header` and `Footer` by doing so like this:
```ts ```ts
doc.Header;
doc.Footer;
```
You can call the same methods as you would with a `File`:
```ts
doc.Header.createParagraph("Header text");
doc.Footer.createParagraph("Footer text");
```
Even add images:
```ts
doc.Header.createImage([BUFFER_OF_YOUR_IMAGE]);
doc.Footer.createImage([BUFFER_OF_YOUR_IMAGE]);
```
Refer to [`8-header-footer`](https://github.com/dolanmiu/docx/blob/master/demo/8-header-footer.ts) for more information.
## Multiple Headers and Footers
Also all the supported section properties are implemented according to: http://officeopenxml.com/WPsection.php
### Example
```ts
const header = this.document.createHeader();
const footer = this.document.createFooter();
// Add new section with another header and footer
doc.addSection({ doc.addSection({
headers: { headers: {
default: header default: new Header({ // The standard default header
children: [],
}),
first: new Header({ // The first header
children: [],
}),
even: new Header({ // The header on every other page
children: [],
}),
}, },
footers: { footers: {
default: footer default: new Footer({ // The standard default footer
children: [],
}),
first: new Footer({ // The first footer
children: [],
}),
even: new Footer({ // The footer on every other page
children: [],
}),
}, },
pageNumberStart: 1, children: [],
pageNumberFormatType: docx.PageNumberFormat.DECIMAL,
}); });
``` ```
If you want more head
## Example
Example showing basic header and footer
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/8-header-footer.ts ":include")
_Source: https://github.com/dolanmiu/docx/blob/master/demo/8-header-footer.ts_
## Multiple Headers and Footers
More headers and footers can be accomplished by creating more `Section`. New headers and footers can be set per `Section`