toDataUrl

API reference for the "toDataUrl" method.

Converts a CanvaImageBlob into a data URL.

Usage

const { imageHelpers } = window.canva;
const canva = window.canva.init();
canva.onReady(async (opts) => {
// Convert a CanvaElement into a CanvaImageBlob
const image = await imageHelpers.fromElement(opts.element);
// Convert the CanvaImageBlob into a data URL
const dataUrl = await imageHelpers.toDataUrl(image);
// Do something with the result
console.log(dataUrl);
});

Parameters

Name

Type

Required

Description

image

CanvaImageBlob

Yes

The CanvaImageBlob to convert into a data URL.

Returns

Promise<string>