关于我的帖子:
关于下述功能:
function submitData(form) {
var subject='New Feedback';
var body=Utilities.formatString('name: %s <br />Email: %s<br />Comment: %s', form.name,form.email,form.comment);
var folderId = "my-folder-ID"; // Please set the folder ID. // Added
var blob = Utilities.newBlob(body, MimeType.HTML, form.name).getAs(MimeType.PDF); // Added
var file = DriveApp.getFolderById(folderId).createFile(blob); // Added
var aliases = GmailApp.getAliases()
Logger.log(aliases); //returns the list of aliases you own
Logger.log(aliases[0]); //returns the alias located at position 0 of the aliases array
GmailApp.sendEmail('[email protected]','From an alias', 'A message from an alias!', {'from': aliases[0],subject: subject,htmlBody: body, attachments: [blob]}); // Modified
// return file.getUrl(); // Modified
return Utilities.formatString('name: %s <br />Email: %s<br />Comment: %s<br />PDF: %s', form.name,form.email,form.comment,file.getUrl());
}
我想将文档用作创建类似于此文档的PDF文件的基本模板:https://jeffreyeverhart.com/2018/09/17/auto-fill-google-doc-from-google-form-submission/如何使用我的应用程序完成此操作?您可以从上方看到这是一个自定义html表单。
提前感谢您的帮助!
form.name,form.email,form.comment
模板文档,然后将其导出为PDF文件。如果我的理解是正确的,那么这个答案怎么样?请认为这只是几个可能的答案之一。
form.name,form.email,form.comment
。然后,将文档转换为PDF数据。运行脚本之前,请准备用作模板的Google文档。
在这种情况下,{{name}}
,{{email}}
和{{comment}}
分别替换为form.name
,form.email
和form.comment
。因此,请在模板文档中包含{{name}}
,{{email}}
和{{comment}}
。
修改脚本后,将如下所示。并将模板Google文档的文件ID设置为templateDocumentId
。
var blob = Utilities.newBlob(body, MimeType.HTML, form.name).getAs(MimeType.PDF);
至:var templateDocumentId = "###"; // Please set the file ID of the template Google Document
var docId = DriveApp.getFileById(templateDocumentId).makeCopy("temp").getId();
var doc = DocumentApp.openById(docId);
var body = doc.getBody();
body.replaceText("{{name}}", form.name).replaceText("{{email}}", form.email).replaceText("{{comment}}", form.comment);
doc.saveAndClose();
var blob = doc.getBlob().setName(form.name);
DriveApp.getFileById(docId).setTrashed(true);
如果我误解了你的问题,而这不是你想要的方向,我深表歉意。