Capturing And Storing Signature to Rhom In Rhomobile Application

Rhomobile has the ability to capture signature using the Signature API. Signature can be captured in two ways,
1. Full Screen Mode
2. Inline Mode
Note : From Rhodes 3.3.3 onwards, the inline mode has been moved on to RhoElement Vs 2 which is a paid version and requires a license to use it.

To use the Signature API, first, we need to add the camera capability in Build.yml,
capabilities:   Camera

Next, on the controller, we need to call the take method of Signature Capture API to show the pre-defined view to capture the signature,

url_for( :action => :signature_callback, :query => { :id => order_id }),
:imageFormat => "jpg",
:penColor => 0x000000,
:penWidth=> 5,
:border => true,
:bgColor => 0xF3F0EB

The SignatureCapture API takes below parameters,

Parameter Allowed Values Default Value Notes
imageFormat jpg, png, bmp jpg Windows – only bmpBlackberry – only png
penColor Any Hex Code 0x000000
penWidth Integer 1
bgColor Any Hex Code 0xFFFFFF
border true, false false

When the user clicks the use button, the callback method is called, and the captured signature image is passed on as parameters. This method is described as below,

def signature_callback

message = "Signature not recieved"
if @params['status'] == 'ok'

order_record = Order.find(@params["id"])
raise "Exception Occured : Record for Order with id as "<a href="mailto:+@params[&quot;id">+@params["id</a>"]+" not found" unless
order_id =
file_name = @params['signature_uri'].to_s().split("/")[2]

# Create signature record in the DB
record = {
:signature_uri => @params['signature_uri'],
:order_id => order_id,
:filename => file_name.to_s
signature = Signature.create(record)

# Move the file to base app path
file_path = File.join(Rho::RhoApplication::get_blob_path(@params['signature_uri']))
file_content = File.binread(file_path)
new_file_path = File.join(Rho::RhoApplication::get_base_app_path(), file_name)
f =, "wb")
message = "Signature recieved successfully"
rescue Exception => e
# Error handling


WebView.navigate( url_for :controller => :Order, :action => :show, :query=> { :id => @params["id"], :message => message } )


That’s how the Rhomobile Signature API is used to capture the user signature and store it to database.

Written By: Ashis Kumar, Software Developer, Mindfire Solutions

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s