Table of Contents

Method SetImageLayout

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

SetImageLayout(WordDocument, ImageRef, ImageAnchor?)

Sets how a picture sits in the text: in line with it, or floating with a wrap, a position and a distance from text.

public static DocumentEdit SetImageLayout(this WordDocument document, ImageRef image, ImageAnchor? anchor)

Parameters

document WordDocument

The document that holds the picture.

image ImageRef

The picture.

anchor ImageAnchor

The floating layout, or null to put the picture in line with text. It is copied; a relative-to left null is the column and the paragraph, a position with neither an offset nor an alignment is an offset of zero, and a RelativeHeight left null keeps the picture's own, or goes above every floating object of the document when the picture was in line.

Returns

DocumentEdit

The edit; Before is just before the picture and After just past it. A layout the picture already has (in line asked to be in line, the same anchor again) gives an empty edit.

Remarks

The picture keeps its place in its paragraph, which is what a floating picture is anchored to; move the anchor with MoveImage(WordDocument, ImageRef, DocumentPosition). A position or a wrap the anchor leaves as the picture has it keeps its markup, so a percentage position and an edited wrap polygon survive a change to something else.

Exceptions

ArgumentNullException

document or image is null.

ArgumentException

The picture is not in document, or not in a paragraph; a relative-to, alignment or wrap-side token is not one the format has; a position has both an offset and an alignment.

ArgumentOutOfRangeException

A distance from text is negative or above MaxAnchorDistance, an offset or a simple position is further than that either way, or the relative height is not an unsigned 32-bit number.

InvalidOperationException

The picture's drawing is not one DrawingML picture, or it is in a shape's text box.