Capturing Signature in Rhomobile Application

Introduction: In Rhomobile, we have the ability to capture signature using the Signature API. The signature API opens a full screen view where user draws its signature and then press the use bytton to store it.
Description: First of all, on the controller, we need to call the take method ofSignatureCapture API to show the pre-defined view to capture the signature.

Rho::SignatureCapture.take(url_for( :action => :signature_callback, :query => { :id => order_id }),  

      { 
           :imageFormat => "jpg",
           :penColor => 0x000000, 
           :penWidth=> 5,   
           :border => true, 
           :bgColor => 0xF3F0EB 
       }  )

And When the user clicks the use button, the callback method is called, and the captured signature image is passed on as parameters,

def signature_callback  message = "Signature not recieved"
        if @params['status'] == 'ok'
                    begin  
                            # Move the file to base app path               sign_name = @params['signature_uri'].to_s().split("/")[2]                 sign_path = File.join(Rho::RhoApplication::get_blob_path(@params['signature_uri']))
                sign_content = File.binread(sign_path)                 new_sign_path = File.join(Rho::RhoApplication::get_base_app_path(), sign_name)          
       f = File.new(new_sign_path, "wb")

                f.write(sign_content)        
          f.close         
        message = "Signature recieved successfully"                             rescue Exception => e 
                # Error handling 
            end                 end
                WebView.navigate( url_for :action => :show,
            :query=> { :signature_name => sign_name, :message => message } )             end 

That’s it. By this simple way we can capture the signature in Rhomobile.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!