Can you make a field in google forms where u can insert mousetrack to make signatures to png format?

Viewed 1411

I having a problem where I want costumers to sign their signature with a tablet pen and send it in to our sheet but never getting the script. I would love some help to get a script there you can sign a field in google form that will show as a png, or make a web app there you can make a sign that I connected to the sign that will send the e sign to the sheet auto.

1 Answers

There are two things you can do

  • Simple: Have the users prepare a signature saved as png beforehand and include into your Google Form a "File upload" item
  • Elegant: Create custom HTML form with a Google Web App and use jSignature

Sample Web App

.gs file

function doGet() {
  return HtmlService
      .createTemplateFromFile('index')
      .evaluate();
}
function saveToDrive(signature){
...
  var signature = signature.split(",")
  var blob = Utilities.newBlob(Utilities.base64Decode(signature[1]), 'image/png');
  var sheet=SpreadsheetApp.getActive().getActiveSheet();
  sheet.insertImage(blob, 1, 1);
...
}

index.html file

<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/></head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/willowsystems/jSignature/master/libs/jSignature.min.js"></script>
<body>
<form>
...
Signature:
<div id="signature"></div><br>
<img id="rendered" src="" style="display:none">
<input type="Submit" value="Save" onclick="getSignature();"/>
...
</form>
</body>
<script>
  document.getElementById("signature").style.border = "1px solid black";
  $("#signature").jSignature({
    'background-color': 'transparent',
    'decor-color': 'transparent'
  });
  function getSignature(){
    $("img#rendered").attr("src",$('#signature').jSignature('getData','default'));
    var signature = document.getElementById('rendered').src;
    google.script.run.saveToDrive(signature);
  } 
</script>
</html>
Related