There are some ways to take screenshot from div in javascript but in LWC, we need to modify to make it LWC compatible.
First write html as follows
in JS you need to import html2canvas.js. you can download this js from this location.
using printDiv function we can create screenshot and display on the page.
Remember we can display image on Canvas as well, but in my case I was getting blurry images on canvas, so instead on canvas i displayed it on img tag.
Thanks for Making my job very easier , very helpful blog Keep sharing more blogs on salesforce
and Can't see inside the js lib
I also get caught (in promise) Unable to find element in cloned iframe
My requirement is kinda same, want to take screenshot/convert lwc component to img/svg format. Using html2canvas as above, it showing this error: caught (in promise) Unable to find element in cloned iframe Any idea?
Hi do you have screen shots of this HTML2CANVAS in action on the LWC? When I copy your example I get an error: [0 .default] is not a function
Do you have any recommendations on how to overcome this?