Method InsertImage
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
documentWordDocumentThe document that holds the position.
atDocumentPositionWhere to insert.
imageBytesbyte[]The image file's bytes.
contentTypestringThe image's content type (
image/png,image/jpeg, …).widthEmuThe displayed width.
heightEmuThe displayed height.
namestringThe drawing's name, or null for "Picture N".
descriptionstringThe alternative text, or null.
Returns
- DocumentEdit
The edit; After is just past the picture.
Exceptions
- ArgumentNullException
document,imageBytesorcontentTypeis null.- ArgumentException
The position is not in
documentor 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.