Skip to content
Document Authoring DA  API Docs v1.10.0
npmGitHub

Image

Image:

{
type: "image";
setExtent(extent: Partial<Extent>): void;
}

Represents an image element within a document.

Image is one of the inline element types that can appear within text content. Images are embedded within paragraphs alongside text and other inline elements. You obtain Image objects by iterating through inline elements and checking their type discriminator.

type: "image"

Type discriminator for inline elements.

Always has the value 'image'. Use this property to narrow the inline element type and access image-specific methods.

extent(): Extent

Gets the current display dimensions of the image.

Extent

An Extent object containing the image’s width and height

Returns the current display size of the image in the document. Dimensions are in points (1 point = 1/72 inch).

if (inline.type === 'image') {
const extent = inline.extent();
console.log(`Image: ${extent.width} x ${extent.height}`);
}

setExtent(extent): void

Sets the display dimensions of the image. Dimensions are in points (1 point = 1/72 inch).

Partial<Extent>

Partial extent object with width and/or height to set

void

Modifies how the image is displayed in the document. You can specify both width and height, or just one dimension. When specifying only one dimension, the other remains unchanged (it does NOT maintain aspect ratio automatically).

This modifies only the display size, not the underlying image data.