Html2Canvas taking a while to take its picture

Answered
0
0

Hi.

I have a situation here using the Html2Canvas extension.

I have created my global Application.ThreadException method and in it the first thing I do is to take a screen-shot of the user current screen. Afterwards, I show a Dialog telling the user something went wrong and asking permission to send an e-mail to the support team collecting the exception message and a picture of the current screen. They can say No and life goes on or permit it and an e-mail will be shot to our support team with the information to be taken care of. All fine. The thing is, apparently the Html2Canvas takes a little while to take the picture and by the time it does it, the Dialog I have just mentioned is already there saying “cheese”. So, the e-mail arrives with the Dialog talking about the Exception on the top of everything.

I have tried Application.Update before calling the Html2Canvas.Screenshot, but that didn’t help.

This is the code I use to take the screen shot:


			Wisej.Web.Ext.Html2Canvas.Html2Canvas.Screenshot((Image Img) =>
			{
				try
				{
					loImage = Img;
					loImage.Save(lcImageTempPath, System.Drawing.Imaging.ImageFormat.Jpeg);
				}
				catch (Exception)
				{
					lcImageTempPath = string.Empty;
				}
			});

So, would you guys know of a way to either have Html2Canvas work faster or to delay the mentioned Dialog to Show up so it wouldn’t be a photo bomber? 🙂

Thanks in advance.

Ivan

  • You must to post comments
Best Answer
0
0

Hi Luca.

Thanks for the prompt reply.

Yep, this is what I am doing already, I show the dialog after the image is saved. But it looks like by the time the Html2Canvas does its thing, the dialog is already there.
Anyway, I will see if I can think of a workaround on this one.

Thanks.

  • Luca
    • Luca
    • Jan 9, 2021 - 7:03 pm
    • 1
    The call is async. Show the dialog after loImage.Save() At that point the image is already done.
  • Ivan Borges
    Oh, OK, I got it now. Found my way. Thanks, Luca.
  • You must to post comments
0
0

Show the dialog after the image is saved. Browser don’t support taking a screenshot, the Html2Canvas extension (using this library) rebuilds the page in a canvas and then converts to an image base64 string, then back to an image object on the server. Another way is to use the new media API but it’s not widely supported and it always pops up an authorization dialog with several options, and doesn’t work well.

When I use the Html2Canvas extension even with complex pages it takes about 1-2 seconds. In any case, there is nothing we can do to change it.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.