我一直在尝试将Google文档文件转换为PDF文件,而无需使用下载选项.下面是我在脚本编辑器中使用的脚本,但它似乎不起作用.我认为错误发生在IF语句之后.
function convertPDF() {
doc = DocumentApp.getActiveDocument();
docblob = DocumentApp.getActiveDocument().getAs('application/pdf');
var result = DocumentApp.getUi().alert(
'Save As PDF?',
'Save current document (Name:'+doc.getName()+') as PDF',
DocumentApp.getUi().ButtonSet.YES_NO);
if (result == DocumentApp.getUi().Button.YES) {
docblob.setName(doc.getName())
folder.createFile(docblob);
DocumentApp.getUi().alert('Your PDF has been converted to a PDF file.');
} else {
DocumentApp.getUi().alert('Request has been cancelled.');
}
}
Run Code Online (Sandbox Code Playgroud)