toDataUrl
API reference for the "toDataUrl" method.
Converts a CanvaImageBlob into a data URL.

Usage

1
const { imageHelpers } = window.canva;
2
const canva = window.canva.init();
3
4
canva.onReady(async (opts) => {
5
// Convert a CanvaElement into a CanvaImageBlob
6
const image = await imageHelpers.fromElement(opts.element);
7
8
// Convert the CanvaImageBlob into a data URL
9
const dataUrl = await imageHelpers.toDataUrl(image);
10
11
// Do something with the result
12
console.log(dataUrl);
13
});
Copied!

Parameters

Name
Type
Required
Description
image
CanvaImageBlob
Yes
The CanvaImageBlob to convert into a data URL.

Returns

Promise<string>
Last modified 1mo ago
Copy link