0

I have Page X with a SignaturePad on my Xamarin.Forms app and I save the signature into the database in the following way:

            if (!sp.IsBlank)
            {
                Stream image = await sp.GetImageStreamAsync(SignatureImageFormat.Png);
                using (BinaryReader br = new BinaryReader(image))
                {
                    br.BaseStream.Position = 0;
                    byte[] SignatureImage = br.ReadBytes((int)image.Length);
                }
            }

I save this byte array in my SQL database table. I navigate to a couple of other pages in my app and then go back to Page X and want to reload all the information into this page from the saved information in the database. How do I reload the Signature? Do I need to save the signature as strokes or points instead? How do I save strokes or points in the database? Some sample code would be really helpful

Thank you.

  • 1
    if you just need to display it for reference I would save the bitmap and display it as an Image. If you actually need to recreate the control, serializing the strokes/points to the db would be better. – Jason Mar 20 '20 at 15:27
  • can you please guide me on how I could serialize strokes/points to the db – lovetolearn Mar 20 '20 at 22:18
  • Use Newtonsoft, there are many examples in the docs – Jason Mar 20 '20 at 22:20
  • use `toData()` this would return an array of points, which then you can use to restore the signature again using `fromData(data)` whenever needed. With this, you can re-save the signature to any other acceptable media directly from the signature pad. – iSR5 Apr 11 '20 at 19:11

0 Answers0