Files
docx-js/docs/usage/headers-and-footers.md

48 lines
1.7 KiB
Markdown
Raw Normal View History

2018-08-04 03:28:27 +01:00
# Headers and Footers
2019-08-03 13:42:24 +01:00
!> Headers and Footers requires an understanding of [Sections](usage/sections.md).
2019-08-21 00:05:46 +01:00
Every Section has a sections which you can define its Headers and Footers:
2018-08-04 03:28:27 +01:00
```ts
2021-03-19 20:53:56 +00:00
const doc = new Document({
sections: [{
headers: {
default: new Header({ // The standard default header on every page or header on odd pages when the 'Different Odd & Even Pages' option is activated
2021-03-19 20:53:56 +00:00
children: [],
}),
first: new Header({ // The header on first page when the 'Different First Page' option is activated
2021-03-19 20:53:56 +00:00
children: [],
}),
even: new Header({ // The header on even pages when the 'Different Odd & Even Pages' option is activated
2021-03-19 20:53:56 +00:00
children: [],
}),
},
footers: {
default: new Footer({ // The standard default footer on every page or footer on odd pages when the 'Different Odd & Even Pages' option is activated
2021-03-19 20:53:56 +00:00
children: [],
}),
first: new Footer({ // The footer on first page when the 'Different First Page' option is activated
2021-03-19 20:53:56 +00:00
children: [],
}),
even: new Footer({ // The footer on even pages when the 'Different Odd & Even Pages' option is activated
2021-03-19 20:53:56 +00:00
children: [],
}),
},
children: [],
}];
2019-08-21 00:05:46 +01:00
});
2018-08-04 03:28:27 +01:00
```
2019-08-21 00:05:46 +01:00
## Example
2018-08-04 03:28:27 +01:00
2019-08-21 00:05:46 +01:00
Example showing basic header and footer
2018-08-04 03:28:27 +01:00
2019-08-21 00:51:26 +01:00
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/8-header-footer.ts ':include')
2018-08-04 03:28:27 +01:00
2019-08-21 00:05:46 +01:00
_Source: https://github.com/dolanmiu/docx/blob/master/demo/8-header-footer.ts_
2018-08-04 03:28:27 +01:00
## Multiple Headers and Footers
2019-08-21 00:05:46 +01:00
More headers and footers can be accomplished by creating more `Section`. New headers and footers can be set per `Section`