w:hdr (Header)
Root element of a header part (header1.xml etc.), containing block-level content rendered in the page header area.
Description
w:hdr is the root element of a header part (header{n}.xml). It is defined in ECMA-376 Part 1 §17.10.4.
The header part is a separate XML file in the OOXML package, linked from the main document via a w:headerReference relationship. w:hdr can contain any combination of paragraphs (w:p) and tables (w:tbl), just like w:body, but must contain at least one paragraph.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | Content is expressed entirely via child paragraphs and tables. |
Examples
<!-- header1.xml -->
<w:hdr xmlns:w="...">
<w:p>
<w:pPr>
<w:jc w:val="right"/>
</w:pPr>
<w:r><w:t>My Document Header</w:t></w:r>
</w:p>
</w:hdr>
var headerPart = mainPart.AddNewPart<HeaderPart>();
string headerId = mainPart.GetIdOfPart(headerPart);
headerPart.Header = new Header(
new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Right }),
new Run(new Text("My Document Header"))));