Table of Contents

Method InsertShape

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

InsertShape(WordDocument, DocumentPosition, string, Emu, Emu, ImageAnchor?)

Inserts a shape as Word's Insert > Shapes does: floating in front of text, in the theme's colours.

public static DocumentEdit InsertShape(this WordDocument document, DocumentPosition at, string preset, Emu width, Emu height, ImageAnchor? anchor = null)

Parameters

document WordDocument

The document that holds the position.

at DocumentPosition

Where the shape is anchored: its paragraph, and its place in the paragraph's text.

preset string

The preset geometry, one of Names ("rect", "ellipse", "rightArrow", …).

width Emu

The width.

height Emu

The height.

anchor ImageAnchor

The position and wrap, or null for NewFloatingAnchor() (at the start of the column and the paragraph, in front of text). It is copied and completed as SetImageLayout(WordDocument, ImageRef, ImageAnchor?) completes an anchor.

Returns

DocumentEdit

The edit; After is just past the shape, which is the inline at Before.

Remarks

The shape takes Word's shape style (the theme's first accent as its fill, a darker shade of it as its line, the light text colour) and an empty centred paragraph in its text box, to type into.

Exceptions

ArgumentNullException

document or preset is null.

ArgumentException

The position is not in document or falls inside a surrogate pair; the preset is not one the format has; an anchor token is not one the format has.

ArgumentOutOfRangeException

A side is not above zero or above MaxImageSide; an anchor's distance or offset is out of range.

InvalidOperationException

The position is inside content a reader synthesized or a shape's text box.