Method InsertShape
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
documentWordDocumentThe document that holds the position.
atDocumentPositionWhere the shape is anchored: its paragraph, and its place in the paragraph's text.
presetstringThe preset geometry, one of Names ("rect", "ellipse", "rightArrow", …).
widthEmuThe width.
heightEmuThe height.
anchorImageAnchorThe 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
documentorpresetis null.- ArgumentException
The position is not in
documentor 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.