> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Other classes: Sections and pages

## `DocumentBackground`

Import from `@reductoai/docx/officejs`.

### DocumentBackground properties

| Name | Type | Description |
| - | - | - |
| `fill` | `DocumentBackgroundFill` | read-only |

## `DocumentBackgroundFill`

The background's fill, named as Word.ShapeFill names its members.

Import from `@reductoai/docx/officejs`.

### DocumentBackgroundFill properties

| Name | Type | Description |
| - | - | - |
| `foregroundColor` | `string` | "#RRGGBB", or "" with no page colour. |
| `type` | `"NoFill" \| "Solid"` | read-only |

### `DocumentBackgroundFill.clear()`

```ts theme={null}
clear(): void
```

Remove the page colour.

### `DocumentBackgroundFill.setSolidColor()`

```ts theme={null}
setSolidColor(color: string): void
```

## `HeaderFooter`

Import from `@reductoai/docx/node`, `@reductoai/docx/officejs`.

### HeaderFooter properties

| Name | Type | Description |
| - | - | - |
| `contentControls` | `ContentControlCollection` | read-only Live controls in this part's own story — the ones authored through `headerFooter.search(text).items[0].insertContentControl(type)`, the door insertContentControl names. |
| `endnotes` | `HandleCollection<object>` | read-only |
| `exists` | `boolean` | read-only Whether a part of this kind/type resolves for the section — its own reference or one inherited from an earlier section (Link to Previous). False means reads see an empty stub and the first write creates the part. Existence is not visibility: FirstPage also needs the section's differentFirstPage flag, EvenPages the document's oddAndEvenPages flag. |
| `fields` | `FieldCollection` | read-only Fields in the part (PAGE/NUMPAGES in footers, STYLEREF in headers); read-only. |
| `font` | `Font` | read-only Direct run formatting over every paragraph in this header/footer part. |
| `footnotes` | `HandleCollection<object>` | read-only |
| `inherited` | `boolean` | read-only True when this section shows an earlier section's part — Word's "Link to Previous": the section declares no reference of its own, so edits land in the shared part and linked sections report the same geometry. False when the section owns the part, and when nothing resolves at all. |
| `inlinePictures` | `HandleCollection<InlinePicture>` | read-only Inline pictures in the part, including table-cell pictures (logos usually sit in cells). |
| `linkedToPrevious` | `boolean` | Word's Link to Previous state for this story type. |
| `paragraphs` | `ParagraphCollection<Paragraph>` | read-only |
| `parentBodyOrNullObject` | `object & { isNullObject: true }` | read-only |
| `parentContentControlOrNullObject` | `object & { isNullObject: true }` | read-only |
| `parentSection` | `Section` | read-only |
| `parentSectionOrNullObject` | `Section & { isNullObject: false }` | read-only |
| `shapes` | `HandleCollection<Shape>` | read-only Floating DrawingML textboxes and pictures anchored in this part. Legacy VML art (w:pict — common for decorative header rectangles and watermarks) is painted by the layout engine but has no handle here. |
| `tables` | `TableCollection<Table>` | read-only Live Table handles scoped to this part (letterhead grids are usually tables). |
| `text` | `string` | read-only The part's text, paragraphs joined with newlines (tabs read as "\t"). |
| `type` | `"Header" \| "Footer"` | read-only |

### `HeaderFooter.clear()`

```ts theme={null}
clear(): void
```

Remove all content, leaving one empty styled paragraph.

### `HeaderFooter.detach()`

```ts theme={null}
detach(): void
```

Clone a shared/inherited part so subsequent edits affect only this section.

### `HeaderFooter.getContentControls()`

```ts theme={null}
getContentControls(options?: ContentControlOptions): ContentControlCollection
```

Same option semantics as Body.getContentControls, over the part's own story.

### `HeaderFooter.getHtml()`

```ts theme={null}
getHtml(): ClientResult<string>
```

As Word: tables as `<table>` (merges as colspan/rowspan), `<h1>-<h6>` for headings,
list markers as text, b/i/u/s/sup/sub and links inline.

### `HeaderFooter.getOoxml()`

```ts theme={null}
getOoxml(): ClientResult<string>
```

Raw WML; a `pkg:package` with its pictures and links when it uses any, so another part can take it.

### `HeaderFooter.getRange()`

```ts theme={null}
getRange(location?: "Start" | "End" | "Whole"): Range
```

A collapsed range at the part's "Start" or "End". Ranges span a single
paragraph, so spans come from `search` or `paragraph.getRange()`.

### `HeaderFooter.getReviewedText()`

```ts theme={null}
getReviewedText(changeTrackingVersion?: "Original" | "Current"): ClientResult<string>
```

The part's own w:ins/w:del projection; the walker is element-driven, so it aligns.

### `HeaderFooter.getTrackedChanges()`

```ts theme={null}
getTrackedChanges(): TrackedChangeCollection
```

The tracked changes in this part's own story.

### `HeaderFooter.insertContentControl()`

```ts theme={null}
insertContentControl(type?: ContentControlType): ContentControl
```

Wrap the whole part, as Body does its story; partial wraps go through a range.

### `HeaderFooter.insertFileFromBase64()`

```ts theme={null}
insertFileFromBase64(
  base64File: DocxFile,
  location?: HeaderFooterInsertLocation,
): Promise<Range>
```

Insert a .docx's body at the part's edge or in its place; async, the file is unpacked here.

### `HeaderFooter.insertInlinePictureFromBase64()`

```ts theme={null}
insertInlinePictureFromBase64(
  base64: string,
  insertLocation?: "Start" | "End",
  options?: InsertInlinePictureOptions,
): InlinePicture
```

### `HeaderFooter.insertOoxml()`

```ts theme={null}
insertOoxml(ooxml: string, location?: HeaderFooterInsertLocation): Range
```

Insert a WML fragment (what `getOoxml` returns) or a Word `pkg:package` at the
part's edge; "Replace" swaps the whole part. A blank edge paragraph gives way
unless the payload ends in a table, which a part cannot end with.

### `HeaderFooter.insertPageNumber()`

```ts theme={null}
insertPageNumber(options?: InsertPageNumberOptions): void
```

Append a page-number paragraph; "\{page}"/"\{pages}" in the template become
live PAGE/NUMPAGES fields (e.g. "Page \{page} of \{pages}"). Centered by
default. A template with a tab is left-aligned: its first "\t" is an alignment tab
to the center of the margins and its second one to the right margin, so the pieces
follow the page setup and not the tab stops of the style.

### `HeaderFooter.insertParagraph()`

```ts theme={null}
insertParagraph(
  text: string,
  location?: HeaderFooterInsertLocation,
  options?: HeaderFooterParagraphOptions,
): Paragraph
```

Append, prepend, or replace a whole paragraph in the Header/Footer style.

### `HeaderFooter.insertTable()`

```ts theme={null}
insertTable(
  rowCount: number,
  columnCount: number,
  location?: "Start" | "End",
  values?: string[][],
  options?: Omit<OfficeRunFormat<InsertTableOptions>, "rows">,
): Table
```

Insert a table at the start or end of this part; `values` fills cells row-major.

### `HeaderFooter.insertText()`

```ts theme={null}
insertText(text: string, location?: HeaderFooterInsertLocation): void
```

Insert text: "Start"/"End" prepend/append a run to the boundary
paragraph; "Replace" swaps the whole part for one paragraph. "\t" and
"\n" become real tab/break elements.

### `HeaderFooter.search()`

```ts theme={null}
search(needle: string, options?: SearchOptions): RangeCollection<Range>
```

Literal search across this part's paragraphs; hits are live Range handles.

### `HeaderFooter.set()`

```ts theme={null}
set(properties: HeaderFooterUpdateData, options?: UpdateOptions): void
```

**Not implemented.** These Office.js members throw: `lists`, `parentBody`, `parentContentControl`, `style`, `styleBuiltIn`, `getComments`, `insertBreak`, `insertHtml`, `select`.

## `LineNumbering`

Line numbers in the margin, off when `w:lnNumType` is absent or counts by 0. As in Word, turning
them off keeps the start, distance and restart (on a `w:countBy="0"` element) for when they come
back on; those stay writable while off, and countBy then reads 1 and ignores a write.

Import from `@reductoai/docx/officejs`.

### LineNumbering properties

| Name | Type | Description |
| - | - | - |
| `countBy` | `number` | Every Nth line shows its number (`w:countBy`). |
| `distanceFromText` | `number` | Points between the numbers and the text; 0 is Word's Auto (no `w:distance`). |
| `isActive` | `boolean` | On when the section carries `w:lnNumType` with a countBy of 1 or more. |
| `restartMode` | `LineNumberingRestart` | `w:restart`: each page (absent), each section, or continuous. |
| `startingNumber` | `number` | The first number shown; `w:start` stores the number before it. |

### `LineNumbering.set()`

```ts theme={null}
set(properties: WritableProperties<LineNumbering>, options?: UpdateOptions): void
```

isActive is applied first, so one batch can switch numbering on and shape it.

## `PageBorder`

One edge of a section's page border.

Import from `@reductoai/docx/officejs`.

### PageBorder properties

| Name | Type | Description |
| - | - | - |
| `artStyle` | `string` | Word.PageBorderArt, or "" for a line border. |
| `artWidth` | `number` | An art border's w:sz is whole points, 1 through 31. |
| `color` | `string` | |
| `colorIndex` | `ColorIndexValue` | The ColorIndex naming this edge's color; "Auto" when none does. |
| `inside` | `boolean` | read-only |
| `isVisible` | `boolean` | |
| `lineStyle` | `string` | An art border reads "None": it is pictures, not a line. |
| `lineWidth` | `number \| BorderWidth` | |
| `location` | `PageBorderLocation` | read-only |

### `PageBorder.set()`

```ts theme={null}
set(properties: PageBorderUpdateData, options?: UpdateOptions): void
```

## `PageBorderCollection`

A section's page border.

Import from `@reductoai/docx/officejs`.

### PageBorderCollection properties

| Name | Type | Description |
| - | - | - |
| `alwaysInFront` | `boolean` | VBA Borders.AlwaysInFront: w:zOrder, front unless it says back. |
| `distanceFrom` | `"PageEdge" \| "Text"` | VBA Borders.DistanceFrom: w:offsetFrom; Word reads an absent one as Text. |
| `distanceFromBottom` | `number` | |
| `distanceFromLeft` | `number` | |
| `distanceFromRight` | `number` | |
| `distanceFromTop` | `number` | VBA Borders.DistanceFromTop: the top edge's w:space in points. |
| `enable` | `boolean` | VBA Borders.Enable: any edge shows. False removes w:pgBorders; true lines every edge that has none. |
| `enableFirstPageInSection` | `boolean` | VBA Borders.EnableFirstPageInSection: w:display is allPages or firstPage. |
| `enableOtherPagesInSection` | `boolean` | VBA Borders.EnableOtherPagesInSection: w:display is allPages or notFirstPage. |
| `items` | `PageBorder[]` | read-only |

### `PageBorderCollection.applyPageBordersToAllSections()`

```ts theme={null}
applyPageBordersToAllSections(): void
```

Copies this section's page border to every section; none here clears them all.

### `PageBorderCollection.set()`

```ts theme={null}
set(properties: PageBorderCollectionUpdateData, options?: UpdateOptions): void
```

## `SectionCollection`

OfficeJS-flavored live collection: `items` is recomputed on every access.

Import from `@reductoai/docx/node`, `@reductoai/docx/officejs`.

### SectionCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `T[]` | read-only |
| `length` | `number` | read-only |

### `SectionCollection.at()`

```ts theme={null}
at(index: number): T
```

### `SectionCollection.getFirst()`

```ts theme={null}
getFirst(): T
```

### `SectionCollection.getFirstOrNullObject()`

```ts theme={null}
getFirstOrNullObject(): T & { isNullObject: boolean }
```

OfficeJS null-object variant; inspect `isNullObject` before other members.

### `SectionCollection.getItem()`

```ts theme={null}
getItem(index: number): T
```

OfficeJS spelling of at().

### `SectionCollection.getLast()`

```ts theme={null}
getLast(): T
```

### `SectionCollection.getLastOrNullObject()`

```ts theme={null}
getLastOrNullObject(): T & { isNullObject: boolean }
```

OfficeJS null-object variant; inspect `isNullObject` before other members.

## `SectionPageSetup`

Raw w:pgSz/w:pgMar reads and writes, in points — DECLARED values, not laid
geometry. The nominal vertical budget for body content is
`pageHeight - bottomMargin`; the laid per-page text-area box comes from
`document.layout.getRects(section)`, whose rects carry `basis: "textArea"`.
Content that stops short of that bottom usually hit an explicit break
(`Paragraph.hasPageBreak`), not the margin.

Not exported by name. You get it from the API.

### SectionPageSetup properties

| Name | Type | Description |
| - | - | - |
| `bottomMargin` | `number` | |
| `differentFirstPageHeaderFooter` | `boolean` | w:titlePg — this section paints its FirstPage header/footer on its first page. |
| `endnoteLocation` | `EndnoteLocation` | VBA Endnotes.Location: EndOfSection or EndOfDocument; document-wide. Extension. |
| `endnoteNumberRestart` | `NoteNumberRestart` | w:endnotePr/w:numRestart — Continuous or EachSection. Extension. |
| `endnoteNumberStart` | `number \| undefined` | w:endnotePr/w:numStart — the endnote counterpart of footnoteNumberStart. Extension. |
| `endnoteNumberStyle` | `NoteNumberStyle` | VBA Endnotes.NumberStyle: w:endnotePr/w:numFmt; LowercaseRoman when absent. Extension. |
| `footerDistance` | `number` | |
| `footnoteLocation` | `FootnoteLocation` | VBA Footnotes.Location: BottomOfPage or BeneathText. Extension. |
| `footnoteNumberRestart` | `NoteNumberRestart` | w:footnotePr/w:numRestart — Continuous, EachSection or EachPage. Extension. |
| `footnoteNumberStart` | `number \| undefined` | w:footnotePr/w:numStart — the number this section's first footnote gets; undefined counts from 1. Extension: Word's Footnote dialog "Start at". |
| `footnoteNumberStyle` | `NoteNumberStyle` | VBA Footnotes.NumberStyle: w:footnotePr/w:numFmt. Extension. |
| `gutter` | `number` | w:pgMar/@w:gutter in points — the binding allowance, added to the inner (or, with w:gutterAtTop, the top) edge on top of the margin. 0 is legal and writes w:gutter='0'; a non-finite or out-of-range value is refused exactly as a margin write is. Pair it with mirrorMargins for a bound book. |
| `gutterPosition` | `GutterPosition` | Left binds the gutter to the side margin; Top is `w:gutterAtTop`, document-wide as in Word. |
| `headerDistance` | `number` | |
| `layoutMode` | `LayoutMode` | w:docGrid/@w:type: Word.LayoutMode. Default keeps the pitch and drops the snap. |
| `leftMargin` | `number` | |
| `lineNumbering` | `LineNumbering` | read-only Word.LineNumbering over this section's `w:lnNumType`. |
| `linePitch` | `number` | w:docGrid/@w:linePitch in points: the Pitch box of Word's Document Grid dialog. Extension. |
| `linesPage` | `number` | Lines per page in the document grid: the text height over the line pitch. |
| `mirrorMargins` | `boolean \| undefined` | w:settings/w:mirrorMargins — the renderer swaps physical left/right margins on even pages, so leftMargin means the INNER edge of a spread. Document-wide, like oddAndEvenPagesHeaderFooter: a write through any section's handle moves the whole document. Reads undefined when the flag is absent; writing false removes it. |
| `oddAndEvenPagesHeaderFooter` | `boolean` | w:evenAndOddHeaders in settings.xml — document-wide, as in Word. |
| `orientation` | `"Portrait" \| "Landscape"` | An explicit pageWidth/pageHeight write afterwards still wins over the swap. |
| `pageHeight` | `number` | |
| `pageNumberFormat` | `string \| undefined` | w:pgNumType/@w:fmt — the printed number's format ("lowerRoman", ...); undefined = decimal. |
| `pageNumberStart` | `number \| undefined` | w:pgNumType/@w:start — the printed number this section restarts at, or undefined when numbering continues from the previous section. Explains why a PAGE field's digits differ from the physical page getRects names. |
| `pageWidth` | `number` | |
| `rightMargin` | `number` | |
| `sectionDirection` | `SectionDirection` | w:sectPr/w:bidi — the section's reading order; absent or off reads LeftToRight. |
| `textColumnCount` | `number` | w:cols/@w:num — the section's equal-width newspaper columns, 1 through 45 (Word's UI limit). 1 is stored as the absent attribute, and it is also the escape hatch: it drops any authored w:col children (and the w:equalWidth flag that described them) and returns the section to one column. A write of 2 or more is refused on an authored unequal grid, and refused when the implied column width falls under Word's 36pt floor. |
| `textColumns` | `TextColumnCollection` | read-only w:sectPr/w:cols as Word's TextColumnCollection: evenly spaced or explicit widths, the line between columns and the flow direction. |
| `textColumnSpacing` | `number` | w:cols/@w:space — the gap between those columns, in points; 36 when absent. Refused when it would squeeze the CURRENT count below the 36pt floor. |
| `topMargin` | `number` | |

### `SectionPageSetup.set()`

```ts theme={null}
set(properties: SectionPageSetupUpdateData, options?: UpdateOptions): void
```

## `TextColumn`

Not exported by name. You get it from the API.

### TextColumn properties

| Name | Type | Description |
| - | - | - |
| `spaceAfter` | `number` | The gap after the column in points; the last column's is 0. |
| `width` | `number` | The column's width in points. |

### `TextColumn.set()`

```ts theme={null}
set(properties: TextColumnUpdateData, options?: UpdateOptions): void
```

## `TextColumnCollection`

Not exported by name. You get it from the API.

### TextColumnCollection properties

| Name | Type | Description |
| - | - | - |
| `items` | `TextColumn[]` | read-only One handle per laid column, left to right in reading order. |

### `TextColumnCollection.add()`

```ts theme={null}
add(options?: TextColumnAddOptions): TextColumn
```

Appends a column. Evenly spaced (the default) raises `@w:num` and, with
`spacing`, sets the shared gap; otherwise the grid turns explicit and the
new column takes `width` (-1 or absent: the last column's) and the column
before it takes `spacing` as its gap.

### `TextColumnCollection.getFlowDirection()`

```ts theme={null}
getFlowDirection(): ClientResult<"RightToLeft" | "LeftToRight">
```

Word ties the column flow to the section's reading order (`w:sectPr/w:bidi`).

### `TextColumnCollection.getHasLineBetween()`

```ts theme={null}
getHasLineBetween(): ClientResult<boolean>
```

### `TextColumnCollection.getIsEvenlySpaced()`

```ts theme={null}
getIsEvenlySpaced(): ClientResult<boolean>
```

### `TextColumnCollection.setCount()`

```ts theme={null}
setCount(numColumns: number): void
```

Arranges the section into `numColumns` evenly spaced columns; 1 is a single column.

### `TextColumnCollection.setFlowDirection()`

```ts theme={null}
setFlowDirection(value: "RightToLeft" | "LeftToRight"): void
```

### `TextColumnCollection.setHasLineBetween()`

```ts theme={null}
setHasLineBetween(value: boolean): void
```

### `TextColumnCollection.setIsEvenlySpaced()`

```ts theme={null}
setIsEvenlySpaced(value: boolean): void
```

True drops the explicit widths; false writes the current equal split as explicit columns.
