Table of Contents

Method InsertFragment

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

InsertFragment(WordDocument, DocumentPosition, DocumentFragment)

Inserts a fragment at a position, as Word pastes with the source formatting kept.

public static DocumentEdit InsertFragment(this WordDocument document, DocumentPosition at, DocumentFragment fragment)

Parameters

document WordDocument

The document that receives the content.

at DocumentPosition

Where it goes.

fragment DocumentFragment

The content. It is not modified and may be inserted again.

Returns

DocumentEdit

The edit; After is just past the inserted content.

Exceptions

ArgumentNullException

document or fragment is null.

ArgumentException

The position is not in document or falls inside a surrogate pair; or the fragment is the document itself.

InvalidOperationException

The position is in a shape's text box, inside content a reader synthesized or an inline content control that cannot hold a paragraph break; or the fragment has note references and the position is in a note.

InvalidDocumentException

The fragment's document can no longer read its media (it was disposed).