Table of Contents

Method AppendImage

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

AppendImage(Paragraph, byte[], string, Emu, Emu, string?, string?)

Appends an inline picture to a paragraph, adding the image bytes to the document's package and recording the relationship the writer needs.

The bytes are materialized in memory, so the image survives the document being saved more than once and does not depend on any source package staying open.

public static ImageRef AppendImage(this Paragraph paragraph, byte[] imageBytes, string contentType, Emu width, Emu height, string? name = null, string? description = null)

Parameters

paragraph Paragraph

The paragraph. It must belong to a document, because the image part and its relationship are document-level state.

imageBytes byte[]

The encoded image bytes. The array is not copied; do not mutate it afterwards.

contentType string

The image content type, for example "image/png".

width Emu

The display width.

height Emu

The display height.

name string

The drawing object name, or null to derive one from the part.

description string

The alternative text, or null.

Returns

ImageRef

The appended image reference.

Exceptions

ArgumentNullException

A required argument is null.

ArgumentException

imageBytes is empty or contentType is not an image type.

InvalidOperationException

The paragraph is not attached to a document.