1)Is there a Google Appscript command that can convert a .gDraw to a .jpg? 2)Can a trigger be set to perform this conversion on .gdraw file edit?

前端 未结 1 584
野性不改
野性不改 2021-01-27 11:20

1)Is there a Google appscript command that can convert a .gDraw to a .jpg?
2)Can a Google trigger be set to perform this conversion on a .gdraw file edit?

1) My answ

相关标签:
1条回答
  • 2021-01-27 11:46

    Use the work-around detailed in comment #22 in the apps script issue 3579 you liked to.

    Important: you must enable Drive API in Advanced Services for your project and in Developers Console for the work-around to work:

    1. In your script project go to menu Resources->Advanced Google services and turn Drive API service on.
    2. Click on Developers Console link at the bottom of the Advanced Google Services dialog box and also enable Drive API there.

    After you have done the above the following code will get your Drawing as JPEG file:

    function gDrawTO_jpeg(){
      var gDrawFile = Drive.Files.get('your_draw_file_ID_here'); 
      var url = gDrawFile.exportLinks['image/jpeg'];
      var token = ScriptApp.getOAuthToken();
      var response = UrlFetchApp.fetch(url, {
        headers: {
          'Authorization': 'Bearer ' +  token
        }
      });
      var jpeg = response.getBlob();
      // save drawing as jpeg file to Drive, or do whatever you need to with the blob
      DriveApp.createFile(jpeg);
    }
    

    As for the second part of your question: no. Google Draw does not support apps script (yet).

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