'how to convert svg inline element to canvas? [duplicate]
Solution 1:[1]
I've trying, and you could use something like the following:
const canvas = document.getElementById("theCanvas");
const svg = document.getElementById("theSvg");
const context = canvas.getContext('2d');
const image = new Image();
image.addEventListener('load', () => {
context.drawImage(image, 0, 0, canvas.width, canvas.height);
}, false);
image.src = URL.createObjectURL(new Blob([svg.outerHTML], {type: 'image/svg+xml'}));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alfredo Tostón |

