Table of Contents

Method FormatSections

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

FormatSections(WordDocument, DocumentSpan, Action<SectionFormat>)

Changes the section formatting (page size, orientation, margins, columns …) of every section a span touches, as Word's page setup does for the sections a selection covers.

public static DocumentEdit FormatSections(this WordDocument document, DocumentSpan span, Action<SectionFormat> change)

Parameters

document WordDocument

The document that holds the span.

span DocumentSpan

The span; an empty span is the section it is in.

change Action<SectionFormat>

Changes a copy of each section's format, which the edit swaps in; undo puts back the instance that was there.

Returns

DocumentEdit

The edit. Its ChangedParagraphKeys are every paragraph of the changed sections, table cells included.

Exceptions

ArgumentNullException

document or change is null.

ArgumentException

The span is not in document.

InvalidOperationException

An end is in a shape's text box, or outside the body (a header, footer or note belongs to no one section).