Posts

Showing posts from September, 2022

Take Screenshot and Download with Blazor WebAssembly

Image
This blog will show you how to take a screenshot with Blazor WebAssembly. There is currently no way to take a screenshot in Blazor. So, in this blog, I'll use the Javascript library html2canvas to capture and download the screenshot. The code below is an index.razor code. In the source code. To use Javascript functions, IJSRuntime is injected. To collect the message, I've added a textbox. This message will be captured in the screenshot. Two new buttons have been added. The first is to take a screenshot, and the second is to download the screenshot. Two methods for taking and downloading screenshots have been added to the @code area. The Javascript methods Takeshot and DownloadImg do not return any values, So I use the InvokeVoidAsync method to call them. index.razor @page   "/" @inject   IJSRuntime   jsRuntime   < h3 > Take Screenshot with Blazor WebAssembly </ h3 >   < div   id = "screenshotContainer"   style = "width