- Home
- Forum
- Xamarin.Forms
- Saving Result of Signature Pad
Saving Result of Signature Pad
Further to the initial query below, I have found that after signing on the signature pad, the control's ImageSource property is null. So I'm very confused about how to save this at the moment.
Just on that last one, I've found that calling the .Save() method on the control is required to populate the ImageSource property.
Greetings from Syncfusion.
We have analyzed your query and yes, we need to call save method for save the signature. We can save the signature by calling Save method of SfSignaturePad control. We have created sample based on your requirement and please find the sample from below.
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/SignaturePadSample-1483474419.zip
Please let us know if you have any other queries.
Regards,
Sakthivel P.
Greetings from Syncfusion.
We have analyzed your query and checked the reported issue with converting bytes to ImageSource and bind the ImageSource to image. Its working as expected, sample we tried that can be download from below.
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/SignaturePadSample-641649167.zip
Could you please check the sample with reported issue and let us know issue resolved are not. If still you are facing the same issue, please modify the sample with reported issue and revert us. It will help us to provide better solution at the earliest.
Regards.
Sakthivel P.
Thanks for the update.
We are glad to know that reported problem has been resolved at your end. Please let us know if you need further assistance on this.
Regards,
Sakthivel P.
How do you save the signature as a jpg/png and so that it can be uploaded to cloud storage (e.g. Firebase Storage)
Nevermind - figured it out from your sample code. For those that were curious, here is what I did:
signaturePad.Save();
if(signaturePad.ImageSource != null)
{
StreamImageSource streamImageSource = (StreamImageSource)signaturePad.ImageSource;
System.Threading.CancellationToken cancellationToken = System.Threading.CancellationToken.None;
Task<Stream> image = streamImageSource.Stream(cancellationToken);
Stream stream = image.Result;
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "sig.png");
using (var fileStream = new FileStream(fileName,FileMode.Create, FileAccess.Write))
{
fileStream.Seek(0, SeekOrigin.End);
await fileStream.WriteAsync(bytes, 0, bytes.Length);
Debug.WriteLine($"Size = {fileStream.Length}");
}
Debug.WriteLine($"{fileName}");
}
We have achieved your requirement by using SfImageEditor. We have assigned the ImageSource of SfSignaturePad to the Source property of SfImageEditor when we click the “ConvertSourceToBytes” button. When we press the "Save as png" button, the sign is saved in the device as a png image.
Please have a sample for your reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SignaturePadSample-114384097
Please check and let us know if you have any concerns.
Regards,
Suganya Sethuraman.
- 10 Replies
- 5 Participants
-
MA Matt
- Dec 7, 2020 03:46 AM UTC
- Jan 13, 2022 01:31 PM UTC