删除Google注释,然后以pdf附件形式发送

时间:2019-07-15 14:34:33

标签: pdf google-apps-script google-sheets

创建文件副本,删除每张纸上的注释,创建文件pdf并将其作为附件发送。电子邮件附件中仍然有注释,但是文件副本不再显示注释。

在删除Google工作表中的注释时已审核的问题,大多数人同意需要进行复制,然后在发送之前删除注释。当前代码将复制并删除注释。尝试创建pdf文件并将其作为附件发送。 pdf附件仍显示注释,但是在google中打开文件,但文件副本中未显示注释。目的是要创建一个没有注释的pdf文件。

function send() {
    var prevMonday = new Date();
    var timestampMonday = prevMonday.setDate(prevMonday.getDate() - (prevMonday.getDay() +6) % 14); 
    function time(s) {
        return new Date(s).toLocaleDateString("en-US");
}
var emailMonday = time(timestampMonday);
var ui = SpreadsheetApp.getUi();

var subject = "Deliveries for week of " + emailMonday;
var body = "Delivery sheet";

var response = ui.prompt("Who should we send to? (list multiple email addresses, separated by commas (,) )", ui.ButtonSet.OK_CANCEL)

if( response.getSelectedButton() == ui.Button.OK ) {

    var ss = SpreadsheetApp.getActive();
    var copyfile = ss.copy("Deliveries");
    var numSheets = copyfile.getNumSheets();
    var allSheets = copyfile.getSheets();
    var x
    for(x=0; x<numSheets; x++)  {
          allSheets[x].clearNotes();
    }
var pdf= DriveApp.getFilesByName("Deliveries").next().getAs('application/pdf').getBytes();
var attach = {fileName:'Deliveries ' + emailMonday + '.pdf',content:pdf, mimeType:'application/pdf'};    

MailApp.sendEmail( response.getResponseText(), subject, body,{attachments: [attach]});
}
}

0 个答案:

没有答案