We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

toDataUrl not is empty

Thread ID:

Created:

Updated:

Platform:

Replies:

142076 Jan 17,2019 12:59 PM UTC Jan 21,2019 12:03 PM UTC ASP.NET Web Forms 5
loading
Tags: Signature
Pio Luca Valvona
Asked On January 17, 2019 12:59 PM UTC

Hi, I used signature control and also if control is empty, but with background, toDataUrl return a base64 string.
Can I return empty value, if control is empty?

Thanks

Deepa Loganathan [Syncfusion]
Replied On January 18, 2019 11:16 AM UTC

Hi Pio Luca,  
 
Greetings from Syncfusion support.  
 
We understood your requirement to return an empty string while setting background image in the Signature control. We have analyzed the feasibility of your requirement and concluded that it is currently not possible to return an empty string when Signature control is rendered with a background image.  
 
This is because while generating data-url, along with the signature content, background image will also be encoded as data-url.  
 
However, you can detect if there is an input to Signature control by comparing the encoded “data-url” strings generated before (that contains only the encoded data of background image) and after changes (data of background image along with signature input) in Signature control in the Change event as depicted in the below code.  
 

var initalurl, newurl; 
               function oncreate(e){  // signature create event 
               
                                           setTimeout(function(){  // set timeout function to get the delay for loading the image in the canvas 
                                            
                                           var obj = $("#apisignature").ejSignature("instance"); 
                                           initalurl = obj._canvas[0].toDataURL(); // take the dataurl and save to a variable 
                                            
                                           }, 1000); 
                                           } 
                                            
                                           function onchange(e){ // signature change event 

                                             newurl = e.lastImage  // take the last drawn image url inside the signature using the lastImage argument 
                                              
                                             initalurl === newurl ? alert("true") : alert("false") // compare to get the difference 
                                           } 
 
For your reference, we have prepared a simple sample in JSplayground.  
 
 
If the solution provided does not meet your requirement, kindly get back to us with the requirement you were trying to achieve in your application. So that we can analyze and provide you a solution that suits your application needs.  
 
Regards,  
Deepa L. 
 


Pio Luca Valvona
Replied On January 18, 2019 02:48 PM UTC

Thank you for your answer. Forgive me for not being clear. I try to explain myself better. I'm using a signature control with an image in the background, even if the control is empty (that is unsigned),  DataUrl returns a value in base64.
How can I tell if there is a signature in the control or is it empty?

Deepa Loganathan [Syncfusion]
Replied On January 18, 2019 05:42 PM UTC

Hi Pio Luca,   
 
We understood your requirement to detect if the Signature control is signed or not by detecting the data-url string.  
 
Solution 1. To detect if there is an input in the signature control in initial rendering 
 
Please check the below help page to check if the Signature control is signed or not in the initial rendering of control. 
 
Solution 2. To detect if there is an input in the signature control after rendering 
 
This can be detected both in server and client side by using the change event of Signature. 
 
Please check our demo pages that showcases the usage of both server and client-side change events.  
 
 
 
Regards,  

Deepa L.
 
 


Pio Luca Valvona
Replied On January 18, 2019 06:15 PM UTC

Hi Deepa,

I tried the first solution, but also in this case, "Storesnap" contains a value, even if there is no signature. I need to assign to a variable, or the empty string value if there is no signature, or the Base64 value if the signature is there. All this at the press of a button on the user control.

Deepa Loganathan [Syncfusion]
Replied On January 21, 2019 12:03 PM UTC

Hi Pio Luca,  
 
We have update our response for your last query in an incident under your Direct Trac account. Please follow up the incident for more details.  
 
  
Please click here to login to your Direct Trac login with the below link.  
  
 
  
Regards,  
Deepa L. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;