Table of Contents

Class DocxHeader

Namespace
DocToolkit
Assembly
DocToolkit.Primitives.dll

The content of one header or footer.

public sealed class DocxHeader
Inheritance
DocxHeader
Inherited Members

Remarks

Footers use this type too. Word's content model for the two is identical, and a second type differing only in its name would be one more thing to learn for no gain.

Attach it with WithHeader(DocxHeader) or WithFooter(DocxHeader); every producer that takes a PageSetup then honours it, with no extra overload.

Properties

Alignment

Where the line sits across the page.

public HeaderAlignment Alignment { get; }

Property Value

HeaderAlignment

Segments

The pieces of the line, in order.

public IReadOnlyList<DocxHeaderSegment> Segments { get; }

Property Value

IReadOnlyList<DocxHeaderSegment>

Methods

Of(HeaderAlignment, params DocxHeaderSegment[])

A header assembled from segments, in order.

public static DocxHeader Of(HeaderAlignment alignment, params DocxHeaderSegment[] segments)

Parameters

alignment HeaderAlignment

Where the line sits.

segments DocxHeaderSegment[]

The pieces, in order. At least one is required.

Returns

DocxHeader

Exceptions

ArgumentNullException

segments, or an entry in it, is null.

ArgumentOutOfRangeException

alignment is not a defined value.

ArgumentException

segments is empty.

Text(string, HeaderAlignment)

A header of a single run of text.

public static DocxHeader Text(string text, HeaderAlignment alignment = HeaderAlignment.Left)

Parameters

text string

The text.

alignment HeaderAlignment

Where it sits. Defaults to Left.

Returns

DocxHeader

Exceptions

ArgumentNullException

text is null.

ArgumentOutOfRangeException

alignment is not a defined value.

ToString()

The segments joined, with fields shown as {PAGE} and {NUMPAGES}.

public override string ToString()

Returns

string