Table of Contents

Method InsertImage

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

InsertImage(WordDocument, DocumentPosition, byte[], string, Emu, Emu, string?, string?)

Inserts an inline picture at a position, splitting a text run there.

public static DocumentEdit InsertImage(this WordDocument document, DocumentPosition at, byte[] imageBytes, string contentType, Emu width, Emu height, string? name = null, string? description = null)

Parameters

document WordDocument

The document that holds the position.

at DocumentPosition

Where to insert.

imageBytes byte[]

The image file's bytes.

contentType string

The image's content type (image/png, image/jpeg, …).

width Emu

The displayed width.

height Emu

The displayed height.

name string

The drawing's name, or null for "Picture N".

description string

The alternative text, or null.

Returns

DocumentEdit

The edit; After is just past the picture.

Exceptions

ArgumentNullException

document, imageBytes or contentType is null.

ArgumentException

The position is not in document or falls inside a surrogate pair, the bytes are empty, or the content type is not an image type the writer stores.

InvalidOperationException

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