CreateImage
Creates an image with the parameters specified.
Syntax
expression.CreateImage(sImageSrc, nWidth, nHeight);
expression - A variable that represents a Api class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| sImageSrc | Required | string | The image source where the image to be inserted should be taken from (currently, only internet URL or Base64 encoded images are supported). | |
| nWidth | Required | EMU | The image width in English measure units. | |
| nHeight | Required | EMU | The image height in English measure units. |
Returns
Example
This example creates an image and pastes it into the document.
- Code
- Result
// How to create an image object using a url and specifying its width and height.
// Create an image and insert it to the slide.
const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const shape = Api.CreateImage(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
60 * 36000, 60 * 36000
);
slide.AddObject(shape);