Google Script - Creating PDF doesn't reflect changes in Document

后端 未结 1 1167
忘了有多久
忘了有多久 2021-01-28 12:51

I have a script in a spreadsheet that receives responses from a Form. Using these responses and a template Google document, I create a new Document from the template and then re

相关标签:
1条回答
  • 2021-01-28 13:30

    You need to use saveAndClose() to update the document before converting it.

    In your code :

    function savePDF(doc) {
      doc.saveAndClose();
      var docblob = doc.getAs('application/pdf');
      var folder =  DocsList.getFolderById(TARGET_FOLDER);
      docblob.setName(doc.getName())
      folder.createFile(docblob);
    }
    

    You don't need the sleep delay, you can remove it unless you want to wait for 15 seconds ;-)

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