toDataUrl
API reference for the "toDataUrl" method.
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);
});
Name | Type | Required | Description |
---|---|---|---|
image | CanvaImageBlob | Yes | The CanvaImageBlob to convert into a data URL. |
Promise<string>
Last modified 1yr ago