Get Started
Plugins
Macros
More information

window.Asc.plugin.executeMethod ("PutImageDataToSelection", [args], callback)

Description

Defines the method that allows replacing the first selected drawing with the image specified in the parameters. If there are no drawings selected, the method inserts the image at the current position.

Usage

This method should be used in the following way:

window.Asc.plugin.executeMethod ("PutImageDataToSelection", [oImageData]);
Parameters
Parameter Description Type Example
oImageData The information about the base64 encoded png image:
  • src - the image source in the base64 format,
    type: string,
    example: "data:image/png;base64,image-in-the-base64-format";
  • nWidth - the image width in pixels,
    type: number,
    example: 300;
  • nHeight - the image height in pixels,
    type: number,
    example: 200.
object
Returns

The method returns the undefined value.

Example
window.saveImage = function () {
    let sImageSrc = imageEditor.toDataURL();
    let editorDimension = imageEditor.getCanvasSize();
    let nWidth = editorDimension.width;
    let nHeight = editorDimension.height;
    let oImageData = {
        "src": sImageSrc,
        "width": nWidth,
        "height": nHeight
    };
    window.Asc.plugin.executeMethod ("PutImageDataToSelection", [oImageData]);
    window.Asc.plugin.executeCommand("close", "");
};