exportImage

Exports a group of drawing elements as an image.

The group will be positioned at [0, 0] in the exported image. Its dimensions will be used as the default dimensions for the image.

Scene images have to be of same origin or CORS-enabled.

The export operation is asynchronous and returns a promise. The promise will be resolved with a PNG image encoded as a Data URI.

import { Path, Text, Group, exportImage } from '@progress/kendo-drawing';
import { saveAs } from '@progress/kendo-file-saver';

export function exportScene() {
  // Create a path and draw a straight line
    const path = new Path({
        stroke: {
            color: `#9999b6`,
            width: 2
        }
    });

    path.moveTo(0, 50).lineTo(200, 50).close();

  // Create the text
    const text = new Text(`Hello World!`, [ 20, 25 ], {
        font: `bold 15px Arial`
    });

  // Place all the shapes in a group
    const group = new Group();
    group.append(path, text);

    exportImage(group).then((data) => {
        saveAs(data, "scene.png");
    });
}

Parameters

group Group

The root group containing all elements to export.

options? ImageExportOptions

The export options.

Returns

Promise<string> A promise that will be resolved with a PNG image encoded as a Data URI.

 /