Signature Field in FileMaker
The script to save is quite easy as it just asks canvas to save its content as base64 encoded png image into the hidden text area. Then uses WebView.GetFormTextAreaValue to query this value, cuts out the header and decodes the base64 image:
Set Variable [ $r ; Value: MBS( "WebView.RunJavaScript" ; "web"; "formtest.output.value = document.getElementsByTagName('canvas')[0].toDataURL('image/png');" ) ]
Set Variable [ $dataURL ; Value: MBS( "WebView.GetFormTextAreaValue" ; "web"; "formtest"; "output"; 0 ) ]
Set Variable [ $p ; Value: Position($DataURL; ","; 1; 1) ]
If [ $p > 0 ]
Set Variable [ $data ; Value: Middle($dataURL; $p + 1; Length($dataURL)) ]
Set Field [ Signature Field::Data ; Base64Decode ( $data; "signature.png" ) ]
End If
We hope you like this example: SignatureField.zip. We'll include it in future plugin releases as an example.
