How can I draw a signature in Xamarin.Forms?

FranciscoGGFranciscoGG ESMember ✭✭
edited December 2015 in Xamarin.Forms

Hi guys,

I am looking for a way to draw signatures from Xamarin.Forms. Is there any plugin which works fine with Xamarin.Forms 1.5?

I have tried with ACR SignaturePad Plugin but it does not work fine on iOS...

Best Answer

Answers

  • 15mgm1515mgm15 USMember ✭✭✭✭

    If you are talking about this one:

    https://components.xamarin.com/view/signature-pad

    I have used it on Android/iOS and it works excellent, or what problems are you experiencing?

  • FranciscoGGFranciscoGG ESMember ✭✭
    edited December 2015

    @15mgm15, how can I use that component in a pure Xamarin.Forms app?

  • FranciscoGGFranciscoGG ESMember ✭✭

    @15mgm15 thanks a lot for the source code, I am goint to take a look, but thanks in advantage!!! :):)

  • FranciscoGGFranciscoGG ESMember ✭✭

    @15mgm15 with your approach would it be possible to catch the image into base64 instead of save as picture?

    I want to get the signature in base64 in order to upload it to server.

  • 15mgm1515mgm15 USMember ✭✭✭✭
    edited December 2015

    @FranciscoGG I have done it the other way around but I am not sure if this will help you:

    http://stackoverflow.com/questions/27710576/convert-from-a-dataurl-to-an-image-in-c-sharp-and-write-a-file-with-the-bytes

    You may need a custom renderer to do a custom renderer/dependency service.

  • 15mgm1515mgm15 USMember ✭✭✭✭

    also I have noticed that the .zip file is gone, for further help this is the file:

  • FranciscoGGFranciscoGG ESMember ✭✭

    @15mgm15, in the ImageWithTouchRenderer.cs file, what is DrawView? I don't find this class.

    Thanks for your time :).

  • 15mgm1515mgm15 USMember ✭✭✭✭

    Whooops sorry here they are:

  • AdamLonsdale.3550AdamLonsdale.3550 GBUniversity ✭✭

    Hi,

    Unless I'm mistaken - the Image won't save on iOS?

    The SavePhotoAndExit routine on iOS will set the SavedImagePath but not actually save the image to the path. Do you have any code that would do this?

    ` void SavePhotoAndExit()
    {
    if (ClickFlag)
    return;

            ClickFlag = true;
    
            string savedFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/temp_" + DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss") + ".jpg";
            DrawingImage.SavedImagePath = savedFileName;
    

    if ANDROID

            Android.Graphics.Bitmap _bitmap = ImageHelper.DecodeSampledBitmapFromResource(savedFileName, 100, 100);
            Byte[] imgBytes = ImageHelper.BitmapToBytes(_bitmap);
            Java.IO.File f = new Java.IO.File(savedFileName + "_");
    
            f.CreateNewFile();
    
            //write the bytes in file
            Java.IO.FileOutputStream fo = new Java.IO.FileOutputStream(f);
            fo.Write(imgBytes);
    
            // remember close de FileOutput
            fo.Close();
    
            savedFileName += "_";
    

    endif

            this.SigData.SignaturePath = savedFileName;
            this.SigData.SignTitle = "Name & Signature";
            this.SigData.DateTimeValue = DateTimeLabel.Text;
            this.SigData.UserName = NameEntry.Text;
            Navigation.PopAsync();
        }`
    
  • FranciscoGGFranciscoGG ESMember ✭✭

    Finally I did it using the example of this App: https://github.com/xamarin/vervetacrm

    Thanks to all of you guys.

  • I am trying to use the code for the signature pad from VervetaCRM and I seem to be getting an empty string in my bound property. I am doing the binding in Xaml though, any ideas what could be going wrong

    Thanks in advance

  • leninmathileninmathi USMember ✭✭

    @15mgm15

    i have implemented the signaturepad for android and ios (cross platform application). in IOS signpad screen not getting closed or not callback into xamarin.forms page (staying on signpad screen itself). any help on this?

  • 15mgm1515mgm15 USMember ✭✭✭✭

    @leninmathi here is an example project without using SignaturePad hope this helps:

  • hopikopitariumhopikopitarium USMember

    @15mgm15 how do you save the path in your project? I get an empty path

  • 15mgm1515mgm15 USMember ✭✭✭✭
    edited May 2016

    @hopikopitarium There is an example on Github please verify it:

    https://github.com/15mgm15/Xamarin-Forms-Signature

  • hopikopitariumhopikopitarium USMember

    @15mgm15 said:
    @hopikopitarium There is an example on Github please verify it:

    https://github.com/15mgm15/Xamarin-Forms-Signature

    Thanks, but I have exactly the same code.
    As I undersand saving should happen on OnElementPropertyChanged method?
    But when I debug and draw something I never come to this point. Can you explain how saving is happening?
    Thanks a lot for sharing anyway!

  • Jeremy.3554Jeremy.3554 USMember

    @15mgm15 said:
    If you are talking about this one:

    https://components.xamarin.com/view/signature-pad

    I have used it on Android/iOS and it works excellent, or what problems are you experiencing?

    xamarin forms

  • PeteSuffolkPeteSuffolk USMember ✭✭

    I have downloaded this https://components.xamarin.com/view/signature-pad and after the far too normal issues with Xamarin it is working.

    I now want to reproduce the code in my own application. Where is the Signature pad documented? Does anyone have a working tutorial for the Signaturepad?

  • Vaka.GopiNadhReddyVaka.GopiNadhReddy USMember ✭✭✭

    i done a small sample on signaturePad by using dependency in xamarin.forms, here it is......

  • VenkataSwamyVenkataSwamy INMember ✭✭✭

    Hi EveryOne,

    I did a sample on SignaturePad

    Here I used CustomRederers and DependencyService concepts.

    In this sample, We are able to get users signature in both iOS and android and we are also able to save it as an image into our local device storage.

    Please find the sample

  • AliImran.7177AliImran.7177 USMember ✭✭

    Venkata Swamy
    You will give this ImagePath=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
    But the Image Will Not save in this Path
    So kindly Tell Me where the Image Will save as soon as possible I will be Waiting For Your Answer

Sign In or Register to comment.