Table of Contents

Method InsertBreak

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

InsertBreak(WordDocument, DocumentPosition, BreakKind)

Inserts a page, column or line break at a position, as Word's Ctrl+Enter, Ctrl+Shift+Enter and Shift+Enter do (WQ-0093).

public static DocumentEdit InsertBreak(this WordDocument document, DocumentPosition at, BreakKind kind)

Parameters

document WordDocument

The document that holds the position.

at DocumentPosition

Where to insert.

kind BreakKind

The break kind.

Returns

DocumentEdit

The edit; After is the start of the paragraph after a page break (the position itself when the break went before a table), just past a column break, or just past a line break.

Remarks

A page break splits the paragraph (as SplitParagraph(WordDocument, DocumentPosition) does) and stands in a paragraph of its own, in the default paragraph style, between the two halves; at a paragraph's start there is no empty first half. In a table cell, at any depth, the break's paragraph goes before the outermost table.

A column break splits the paragraph and starts the second half; at a paragraph's start it goes in at offset 0. A line break goes in at the position, formatted as text typed there would be (WQ-0089).

Exceptions

ArgumentNullException

document is null.

ArgumentException

The position is not in document, or falls inside a surrogate pair.

ArgumentOutOfRangeException

kind is not a defined break kind, or the offset is outside the paragraph's content.

InvalidOperationException

A page or column break in a header, footer, note or text box, or a column break in a table cell (Word refuses both); or the position is inside an inline content control or content a reader synthesized.