Saving image to Spreadsheet with Google Scripts

前端 未结 1 1755
借酒劲吻你
借酒劲吻你 2021-01-27 08:07

I\'m trying to add a signature pad to a Google Sheet using jSignature. I\'ve added a dialog box that records the signature like this:

//Code.gs
function showDial         


        
1条回答
  •  别那么骄傲
    2021-01-27 08:33

    To the save the image to your Drive you can do something like this

    Your Html Code:

    
    
    
    Please draw your signature on the signature pad below: 
    
    

    Server side code:

    function showDialog() {
      var html = HtmlService.createHtmlOutputFromFile('Sign')
        .setWidth(400)
        .setHeight(300);
    SpreadsheetApp.getUi()
      .showModalDialog(html, 'Your Signature is Required');
    }
    
    function saveImage(bytes){
      var bytes = bytes.split(",")
      var blob = Utilities.newBlob(Utilities.base64Decode(bytes[1]), 'image/png');
      blob.setName("Sign Pic")
      DriveApp.getFolderById("Folder ID to save SignPic").createFile(blob)
    }
    

    You will have to keep track of names of image files and insert the pics into the spreadsheet accordingly.

    0 讨论(0)
提交回复
热议问题