NetTalk Central

Author Topic: New Form Field Type: Signature  (Read 10821 times)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
New Form Field Type: Signature
« on: April 23, 2013, 07:19:22 AM »
Build 7.08 sees the inclusion of a new Form Field Type, called "Signature".
This (in concept) allows the user to enter a "free form" signature on a form, which is then stored in the database and displayed back to the user when they view the form later on.

Caveats

The basic field works well, but your mileage may vary depending on the input mechnism. For example, writing a signature with a mouse is quite hard, and writing it with a finger on a phone is very coarse.

On a "slow" phone it also pays to move your finger slowly, and (again on some phones) it sometimes pays to place the finger in the field, wait a bit, and then start drawing. the slower the phone, and the older the browser, the more likely there are to be issues. So I recommend testing on a specific device before assuming it'll work on that device.

I've also seen it not work at all with the Opera browser on one phone, but work with the built-in browser on the same phone, so again some caution and testing recommended.

Storage

The result is stored as a "string" of data. The length of the string can depend a lot on how long the signature is. In my testing, and example, I've used a MEMO(64000) to hold it. All the chars in the string are "text" not "binary", so it should be very compatible with whatever backend you use.

The received text is a string of co-ordinates which maps the signature picture, and it can be converted into a BMP if you desire. This might be useful if, for example, you want to use the signature on a report. The example uses CapeSoft DRAW to convert the string to an image, but you could use another tool to do this if you prefer. NetTalk has a "hook" into a conversion procedure, and an example conversion procedure is in the attached example.
(Called SigToImage, it relies on the Draw accessory.)

Global Settings

Globally - turn on the Signature Script in the WebServer procedure, NetTalk Extension, Scripts tab.

Local Settings Tab

Width, Height : The size of the box into which the signature will be draw & displayed.

Allow on Insert Only : Only allow signatures to be drawn when the form is in Insert mode. In other modes (Change / View) the signature will be visible (ie redrawn), but cannot be changed.

Include Clear Button : Includes a button "clear" which allows the signature field to be cleared, so the user can start again.

Include Guide Line: Includes a light grey line as the background for the user to sign onto.

Local Save Tab

Save Signatures as Image File : If on will call a procedure to convert the signature to an image. this is in addition to storing the image in the data field.

Save to file on Insert / Save to file on Change: Save the image when a record is created, and/or save it when the record is changed.

Procedure : the procedure in your app to do the conversion. (Typically SigToImage)

FileName : The name of the file to save the signature as. You could use the record ID as part of the name. For example;
'Sign-' & p_web.GSV('fil:id') & '.bmp'

Format

(This is included FYI, but you don't really need to care about this.)

The format of the string looks like this;

Z[{XxxYyyWwwHhh-XxxYyyWwwHhh-.....-XxxYyyWwwHhh}]

Each instance of xx, yy, ww and hh is a number.

Each group matches a call to draw a LINE(xx,yy,ww,hh)
The signature is formed from all of these "little lines"

SigToImage  

The template allows you to "call" a procedure to convert the lines to an image, when the signature is submitted. the procedure can have any name, but the prototype must be (compatible with)
Procedure(String pSig,Long pWidth,Long pHeight,String pFileName)
as these are settings that come from the template.

An example sigToImage function is included in the attached example. This procedure uses the DRAW library to draw the lines, and save the image.

The source code for this example procedure is as follows;

SigToImage PROCEDURE (String pSig,Long pWidth,Long pHeight,String pFileName)
drw     draw
Window  WINDOW('Caption'),AT(,,200,60),GRAY
          IMAGE,AT(0,0,200,60),USE(?Draw)
        END      
st     stringTheory
liner  stringTheory
ln  long
x  long
y  long
w  long
h  long
a  long
b  long        

  CODE

  open(window)
  window{prop:pixels} = 1
  window{prop:width} = pWidth
  window{prop:height} = pHeight
  ?Draw{prop:width} = pWidth
  ?Draw{prop:height} = pHeight
  drw.init(?Draw)
  st.SetValue(pSig)    
  st.remove('Z[{{')
  st.split('-')        
  drw.Blank(color:white)        
  drw.SetPenColor(color:black)
  drw.SetPenWidth(1)
  loop ln = 1 to st.records()
    liner.setvalue(st.GetLine(ln))
    x = liner.between('X','Y')
    y = liner.between('Y','W')
    w = liner.between('W','H') - x
    h = liner.after('H') - y
    drw.Line(x,y,w,h)
  end
  drw.display()  
  drw.WriteBMP(pFileName)
  drw.kill()
  close(window)


« Last Edit: April 23, 2013, 07:21:39 AM by Bruce »

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: New Form Field Type: Signature
« Reply #1 on: April 26, 2013, 04:23:37 PM »
why? can not change the signature in change mode?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New Form Field Type: Signature
« Reply #2 on: April 28, 2013, 05:42:20 AM »
see local settings;

Allow on Insert Only : Only allow signatures to be drawn when the form is in Insert mode. In other modes (Change / View) the signature will be visible (ie redrawn), but cannot be changed.

This is on the "Settings" tab.
« Last Edit: April 29, 2013, 09:22:58 PM by Bruce »

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: New Form Field Type: Signature
« Reply #3 on: May 10, 2013, 09:58:57 AM »
i have a problem with signature, when save via mobile don't work, i see the data in my database but don't display .

try in http://track.magictransport.com:88/SearchForSignature and use number 2 to see what happen after save with mobile..

with normal browser,  work perfect

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New Form Field Type: Signature
« Reply #4 on: May 11, 2013, 12:47:06 AM »
what browser, in what OS, is it failing on?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New Form Field Type: Signature
« Reply #5 on: May 11, 2013, 12:47:51 AM »
and what version of the OS - what version of the browser?

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: New Form Field Type: Signature
« Reply #6 on: May 11, 2013, 01:21:51 AM »
HTC Phone,my browser is dolphin a my os is android 2.3.4, i try with galaxy note with android ice cream and internal browser(don't version) but same problem.


osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: New Form Field Type: Signature
« Reply #7 on: May 11, 2013, 11:43:11 AM »
same problem with iphone and safari..

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New Form Field Type: Signature
« Reply #8 on: May 12, 2013, 09:57:17 PM »
maybe your database is not holding all the data correctly? ie if the field is not big enough it will be truncated, and this would be a problem. So what backend are you using? and how is the field declared in your dictionary?

cheers
Bruce

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: New Form Field Type: Signature
« Reply #9 on: May 13, 2013, 03:59:34 AM »
my backend is SQL Server and data type is varchar(max) in my dct is cstring(65535).

this problem only ocurrs with mobile browser, with normal browser, work perfect.

Signature value in database:

Z[{X10Y6W10H5-X4Y17W10H6-X4Y19W4H17-X5Y21W4H19-X6Y23W5H21-X11Y28W6H23-X13Y30W11H28-X15Y32W13H30-X21Y34W15H32-X27Y34W21H34-X31Y34W27H34-X34Y34W31H34-X39Y32W34H34-X41Y31W39H32-X44Y29W41H31-X46Y28W44H29-X48Y26W46H28-X50Y25W48H26-X53Y21W50H25-X54Y19W53H21-X56Y14W54H19-X55Y8W56H14-X54Y5W55H8-X53Y2W54H5-X49Y-5W53H2-X46Y-7W49H-5-X43Y-10W46H-7-X35Y-12W43H-10-X30Y-12W35H-12-X25Y-10W30H-12-X16Y-6W25H-10-X12Y-3W16H-6-X5Y2W12H-3-X3Y9W5H2-X47Y17W47H16-X47Y24W47H17-X48Y28W47H24-X50Y31W48H28-X51Y32W50H31-X52Y32W51H32-X52Y30W52H32-X53Y27W52H30-X53Y26W53H27-X55Y21W53H26-X58Y19W55H21-X61Y18W58H19-X64Y18W61H18-X65Y19W64H18-X67Y20W65H19-X69Y23W67H20-X69Y26W69H23-X69Y30W69H26-X68Y31W69H30-X67Y33W68H31-X66Y34W67H33-X65Y34W66H34-X64Y34W65H34-X64Y32W64H34-X64Y31W64H32-X65Y26W64H31-X66Y24W65H26-X69Y20W66H24-X70Y18W69H20-X72Y18W70H18-X73Y18W72H18-X76Y18W73H18-X81Y21W76H18-X82Y22W81H21-X84Y24W82H22-X85Y28W84H24-X85Y31W85H28-X84Y34W85H31-X83Y35W84H34-X109Y14W109H13-X98Y14W109H14-X90Y17W98H14-X88Y18W90H17-X84Y22W88H18-X83Y24W84H22-X84Y26W83H24-X87Y28W84H26-X91Y29W87H28-X95Y30W91H29-X99Y30W95H30-X102Y29W99H30-X104Y28W102H29-X109Y25W104H28-X110Y24W109H25-X111Y23W110H24-X112Y20W111H23-X112Y19W112H20-X111Y18W112H19-X110Y18W111H18-X109Y18W110H18-X108Y18W109H18-X107Y19W108H18-X107Y20W107H19-X107Y21W107H20-X107Y24W107H21-X108Y25W107H24-X109Y26W108H25-X111Y27W109H26-X112Y27W111H27-X115Y27W112H27-X116Y26W115H27-X119Y24W116H26-X121Y22W119H24-X123Y21W121H22-X124Y21W123H21-X125Y21W124H21-X127Y24W125H21-X127Y29W127H24-X128Y34W127H29-X131Y38W128H34-X132Y40W131H38-X192Y2W192H1-X181Y1W192H2-X175Y1W181H1-X176Y1W175H1-X169Y3W176H1-X168Y4W169H3-X165Y5W168H4-X163Y6W165H5-X161Y7W163H6-X160Y9W161H7-X160Y10W160H9-X160Y12W160H10-X165Y15W160H12-X169Y17W165H15-X176Y19W169H17-X182Y21W176H19-X186Y22W182H21-X187Y23W186H22-X190Y25W187H23-X191Y26W190H25-X192Y27W191H26-X190Y31W192H27-X186Y33W190H31-X179Y34W186H33-X207Y18W207H17-X199Y13W207H18-X197Y14W199H13-X195Y16W197H14-X193Y17W195H16-X191Y19W193H17-X190Y21W191H19-X192Y24W190H21-X196Y26W192H24-X198Y26W196H26-X202Y25W198H26-X206Y23W202H25-X208Y22W206H23-X209Y21W208H22-X210Y20W209H21-X211Y18W210H20-X212Y18W211H18-X212Y19W212H18-X212Y21W212H19-X211Y27W212H21-X210Y30W211H27-X209Y34W210H30-X209Y37W209H34-X208Y41W209H37-X208Y45W208H41-X208Y47W208H45-X208Y48W208H47-X208Y49W208H48-X210Y49W208H49-X211Y48W210H49-X220Y17W220H16-X222Y24W220H17-X224Y25W222H24-X226Y26W224H25-X230Y26W226H26-X231Y25W230H26-X234Y23W231H25-X237Y21W234H23-X238Y19W237H21-X240Y17W238H19-X240Y16W240H17-X240Y15W240H16-X239Y16W240H15-X238Y20W239H16-X238Y21W238H20-X239Y23W238H21-X240Y25W239H23-X242Y26W240H25-X243Y27W242H26-X244Y27W243H27-X246Y27W244H27-X248Y26W246H27-X249Y25W248H26-X251Y23W249H25-X252Y22W251H23-X253Y20W252H22-X253Y19W253H20-X254Y17W253H19-X254Y16W254H17-X254Y17W254H16-X255Y18W254H17-X256Y19W255H18-X256Y20W256H19-X258Y22W256H20-X258Y23W258H22-X260Y25W258H23-X262Y27W260H25-X263Y28W262H27-X264Y28W263H28-X266Y28W264H28-X268Y28W266H28-X269Y27W268H28-X282Y15W282H14-X271Y7W282H15-X271Y11W271H7-X269Y14W271H11-X272Y17W269H14-X280Y19W272H17-X286Y18W280H19-X292Y17W286H18-X295Y12W292H17-X297Y13W295H12-X296Y14W297H13-X295Y19W296H14-X295Y24W295H19-X296Y27W295H24-X297Y28W296H27-X299Y30W297H28-X302Y30W299H30-X304Y31W302H30-X300Y4W300H3-X302Y12W300H4-X303Y13W302H12-X304Y15W303H13-X305Y17W304H15-X306Y20W305H17-X307Y23W306H20-X307Y24W307H23-X308Y25W307H24-X308Y26W308H25-X306Y25W308H26-X305Y24W306H25-X304Y23W305H24-X302Y22W304H23-X301Y20W302H22-X300Y17W301H20-X300Y16W300H17-X300Y13W300H16-X301Y12W300H13-X302Y10W301H12-X305Y8W302H10-X306Y7W305H8-X309Y7W306H7-X310Y6W309H7-X314Y7W310H6-X315Y8W314H7-X317Y10W315H8-X318Y14W317H10-X319Y18W318H14-X317Y22W319H18-X315Y24W317H22-X311Y26W315H24-X307Y26W311H26-X305Y26W307H26-X304Y25W305H26-X304Y23W304H25-X305Y21W304H23-X305Y20W305H21-X306Y19W305H20-X316Y16W316H15-X319Y24W316H16-X319Y28W319H24-X319Y29W319H28-X318Y30W319H29-X317Y31W318H30-X318Y30W317H31-X318Y29W318H30-X320Y26W318H29-X321Y24W320H26-X324Y20W321H24-X326Y18W324H20-X328Y17W326H18-X331Y14W328H17-X333Y13W331H14-X334Y13W333H13-X334Y12W334H13-X334Y13W334H12-X333Y14W334H13-X332Y15W333H14-X332Y16W332H15-X332Y18W332H16-X332Y19W332H18-X332Y22W332H19-X332Y23W332H22-X334Y23W332H23-X336Y24W334H23-X337Y24W336H24-X339Y24W337H24-X342Y23W339H24-X345Y22W342H23-X348Y20W345H22-X349Y19W348H20-X350Y18W349H19-X350Y17W350H18-X351Y15W350H17-X351Y12W351H15-X350Y8W351H12-X347Y8W350H8-X256Y4W256H3}]

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: New Form Field Type: Signature
« Reply #10 on: May 13, 2013, 10:01:44 AM »
I started my project as a mobile site on my pc localhost,save and view signature perfect, the only failure in mobile.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New Form Field Type: Signature
« Reply #11 on: May 14, 2013, 04:42:15 AM »
I'm not having the same problem here.
Do you get the same problem using the example app?
That will tell us where to look next for the problem.

cheers
Bruce