Files
docx-js/docs/usage/headers-and-footers.md
2021-03-19 20:53:56 +00:00

1.3 KiB

Headers and Footers

!> Headers and Footers requires an understanding of Sections.

Every Section has a sections which you can define its Headers and Footers:

const doc = new Document({
    sections: [{
        headers: {
            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: {
            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: [],
            }),
        },
        children: [],
    }];
});

Example

Example showing basic header and footer

Example

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