Export (0) Print
Expand All

HeaderReference class

Header Reference. When the object is serialized out as xml, its qualified name is w:headerReference.

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

public class HeaderReference : HeaderFooterReferenceType

[ISO/IEC 29500-1 1st Edition]

headerReference (Header Reference)

This element specifies a single header which shall be associated with the current section in the document. This header shall be referenced via the id attribute, which specifies an explicit relationship to the appropriate Header part in the WordprocessingML package.

If the relationship type of the relationship specified by this element is not http://schemas.openxmlformats.org/officeDocument/2006/header, is not present, or does not have a TargetMode attribute value of Internal, then the document shall be considered non-conformant.

Within each section of a document there can be up to three different types of headers:

  • First page header

  • Odd page header

  • Even page header

The header type specified by the current headerReference is specified via the type attribute.

If any type of header is omitted for a given section, then the following rules shall apply.

  • If no headerReference for the first page header is specified and the titlePg element is specified, then the first page header shall be inherited from the previous section or, if this is the first section in the document, a new blank header shall be created. If the titlePg element is not specified, then no first page header shall be shown, and the odd page header shall be used in its place.

  • If no headerReference for the even page header is specified and the evenAndOddHeaders element is specified, then the even page header shall be inherited from the previous section or, if this is the first section in the document, a new blank header shall be created. If the evenAndOddHeaders element is not specified, then no even page header shall be shown, and the odd page header shall be used in its place.

  • If no headerReference for the odd page header is specified then the even page header shall be inherited from the previous section or, if this is the first section in the document, a new blank header shall be created.

[Example: Consider a three page document with different first, odd, and even page header defined as follows:

This document defines three headers, each of have a relationship from the document part with a unique relationship ID, as shown in the following packaging markup:

<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  …
  <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header1.xml" />
  <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header2.xml" />
  <Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="header3.xml" />
  …
</Relationships>

These relationships are then referenced in the section's properties using the following WordprocessingML:

<w:sectPr>
  …
  <w:headerReference r:id="rId3" w:type="first" />
  <w:headerReference r:id="rId5" w:type="default" />
  <w:headerReference r:id="rId2" w:type="even" />
  …
</w:sectPr>

The resulting section must use the header part with relationship id rId3 for the first page, the header part with relationship id rId2 for all subsequent even pages, and the header part with relationship id rId5 for all subsequent odd pages. end example]

Parent Elements

sectPr (§17.6.17); sectPr (§17.6.18)

Attributes

Description

id (Relationship to Part)

Namespace: .../officeDocument/2006/relationships

Specifies the relationship ID to a specified part.

The specified relationship shall match the relationship type required by the parent element:

  • http://schemas.openxmlformats.org/officeDocument/2006/customXml for the contentPart element

  • http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer for the footerReference element

  • http://schemas.openxmlformats.org/officeDocument/2006/relationships/header for the headerReference element

  • http://schemas.openxmlformats.org/officeDocument/2006/relationships/font for the embedBold, embedBoldItalic, embedItalic, or embedRegular elements

  • http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings for the printerSettings element

  • http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink for the longDesc or hyperlink element

[Example: Consider an XML element which has the following id attribute:

<… r:id="rId10" />

The markup specifies the associated relationship part with relationship ID rId1 contains the corresponding relationship information for the parent XML element. end example]

The possible values for this attribute are defined by the ST_RelationshipId simple type (§22.8.2.1).

type (Header or Footer Type)

Specifies the type of header or footer specified by the target relationship ID. This header/footer type determines the page(s) on which the current header or footer shall be displayed.

If any section contains more than a single header or footer of each type, then the document shall be considered non-conformant.

[Example: Consider a document with the following WordprocessingML:

<w:sectPr>
  …
  <w:footerReference r:id="rId6" w:type="first" />
  <w:footerReference r:id="rId7" w:type="first" />
  <w:footerReference r:id="rId10" w:type="even" />
  …
</w:sectPr>

The resulting section has two footers of type first, and therefore is non-conformant. end example]

[Example: Consider a WordprocessingML section which specifies the following header reference:

<w:headerReference r:id="rId10" w:type="first" />

The resulting section must use the specified header part for the first page. end example]

The possible values for this attribute are defined by the ST_HdrFtr simple type (§17.18.36).

[Note: The W3C XML Schema definition of this element’s content model (CT_HdrFtrRef) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft