I have canvas element (I use Fabric.JS). On the screen below canvas there is Dom textarea
.
I have download button, it works – it downloads canvas
element as image.
However, I need to add text in textarea
text also into this download image. It should be below canvas
.
How this should be done? I do not have an idea how to implement this trick?
Code (it is typescript and used in React app, but it doesn’t matter here I guess, because if it would be pure Javascript idea would be the same – create dummy a element and trigger click)
const url = canvas.toDataURL({
format: "png",
width,
height,
});
const a = document.createElement("a");
a.href = url;
a.download = "download";
const clickHandler = () => {
setTimeout(() => {
URL.revokeObjectURL(url);
a.removeEventListener("click", clickHandler);
a.remove();
}, 150);
};
a.addEventListener("click", clickHandler, false);
a.click();
118480 629860Your weblog has the same post as an additional author but i like your far better.~:; 661659
250150 69830You created various excellent points there. I did a search on the subject and found most people will have exactly the same opinion with your weblog. 773159
46785 204614Excellent support from this weblog! Thanks alot for the details I necessary 676466
372117 223244Some truly marvelous work on behalf of the owner of this internet web site , dead great articles . 660966