Image
Image:
Represents an image element within a document.
Remarks
Section titled “Remarks”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.
Properties
Section titled “Properties”type:
"image"
Type discriminator for inline elements.
Remarks
Section titled “Remarks”Always has the value 'image'. Use this property to narrow the inline element
type and access image-specific methods.
Methods
Section titled “Methods”extent()
Section titled “extent()”extent():
Extent
Gets the current display dimensions of the image.
Returns
Section titled “Returns”An Extent object containing the image’s width and height
Remarks
Section titled “Remarks”Returns the current display size of the image in the document. Dimensions are in points (1 point = 1/72 inch).
Example
Section titled “Example”if (inline.type === 'image') { const extent = inline.extent(); console.log(`Image: ${extent.width} x ${extent.height}`);}setExtent()
Section titled “setExtent()”setExtent(
extent):void
Sets the display dimensions of the image. Dimensions are in points (1 point = 1/72 inch).
Parameters
Section titled “Parameters”extent
Section titled “extent”Partial<Extent>
Partial extent object with width and/or height to set
Returns
Section titled “Returns”Remarks
Section titled “Remarks”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.