SfSignature

signature.SaveAsync

I see where to set file image type and file name but not how to save signature image in specific folder 

thanks 


5 Replies

JS Janakiraman Sakthivel Syncfusion Team December 28, 2021 04:20 PM UTC

Hi Clark Brown, 
 
Thank you for contacting Syncfusion support. 

We can set the file image type and file name by using the fileType and fileName arguments in the SaveAsync() method as shown below. 
 
 
[Index.razor]:  
private async Task onSave() 
{ 
      await signature.SaveAsync(fileType: SignatureFileType.Png, fileName: "Enter the file name here" ); 
} 
  
For your convenience, we have prepared the sample based on your requirement. Please find the link below. 
 
 
Could you please check the above link and get back to us, if you need any further assistance on this.  
 
Regards, 
Janakiraman S. 



CB Clark Brown December 28, 2021 04:31 PM UTC

I understood how to set file type and name, the issue is it saves the signature file in downloads folder, how do I specify a different folder to save file.

I have tried using full path and name in filename, it still writes image file in downloads folder.


thanks 



JS Janakiraman Sakthivel Syncfusion Team December 29, 2021 04:01 PM UTC

Hi Clark Brown,  

We can achieve your reported requirement "want to save the signature image in a specific folder" in our signature component. As shown below, we convert the signature as Base64 string by GetSignatureAsync() method then convert this Base64 string to an equivalent
byte array by Convert.FromBase64String() method for save the signature image in a specific folder. 
 
[Index.razor]:  
 
private async Task onSave() 
    { 
        //To save in a specific folder 
        string path = @"D:\Download\"; 
        string base64image = await signature.GetSignatureAsync(SignatureFileType.Png); 
        var filepath = path + "signature.png"; 
        using (FileStream fs = new FileStream(filepath, FileMode.CreateNew)) 
        { 
            using (BinaryWriter bw = new BinaryWriter(fs)) 
            { 
                string convert = base64image.Replace("data:image/png;base64,", String.Empty); 
                byte[] data = Convert.FromBase64String(convert); 
                bw.Write(data); 
                bw.Close(); 
            } 
         } 
      clearDisabled = true; 
      } 
  
For your convenience, we have prepared the sample based on your requirement. Please find the link below. 
 
 
Could you please check the above link and get back to us, if you need any further assistance on this.  
 
Regards, 
Janakiraman S.


CB Clark Brown December 29, 2021 04:04 PM UTC

thank you 



JS Janakiraman Sakthivel Syncfusion Team December 30, 2021 06:34 AM UTC

Hi Clark Brown, 
  
We are happy to hear that your requirement has been achieved. Kindly get back to us if you need any further assistance.  
  
Regards,  
Janakiraman S.  


Loader.
Up arrow icon