[英]How do I add my Google Apps Script signature code within my Google Forms
[英]I would like to add download functionality to my google apps script
在一些在線教程的幫助下,我整理了一個駐留在我的谷歌表格中的腳本,該腳本根據我的模板提交表單以生成我的信。
一切正常,但在保存 PDF 文件后的最后一部分,我想添加到下載文件的選項中,並彈出一個問題。
“您要下載 PDF”[是][否]
我無法理解如何實現它。
這是我沒有下載選項的代碼:
function jobFillGoogleDocFromForm(e) {
//e.values is an array of form values
var timestamp = e.values[0];
var jobType = e.values[1];
var jobTitle = e.values[2];
var companyName = e.values[3];
var now = new Date();
var day = now.getDate() +1;
var month = now.getMonth();
var year = now.getFullYear();
var todaysDate = day+'/'+month+'/'+ year
//determine which cover letter template to use based on the job type
if (jobType == '3D Art') {
var file = DriveApp.getFileById('1kENGdn8fALXPle28xHO2SCNsuHZiI1k4ckQhRlHJHoU');
} else {
var file = DriveApp.getFileById('1lSrtlBvzvMiL6YAdSSAUiHvHPVG_DAsopQIo3nr6924');
}
//We can make a copy of the template, name it, and optionally tell it what folder to live in
//file.makeCopy will return a Google Drive file object
var folder = DriveApp.getFolderById('1tS3CRWI2Vrh4RzS96n0I4lrktxLhCL6s')
var copy = file.makeCopy('AndreaMele_Cover_Letter' + '_' + jobTitle + ' - ' + companyName, folder);
//Once we've got the new file created, we need to open it as a document by using its ID
var doc = DocumentApp.openById(copy.getId());
//Since everything we need to change is in the body, we need to get that
var body = doc.getBody();
//Then we call all of our replaceText methods
body.replaceText('{{todaysDate}}', todaysDate);
body.replaceText('{{jobTitle}}', jobTitle);
body.replaceText('{{companyName}}', companyName);
//Save and close the document to persist our changes
doc.saveAndClose();
//Save out a copy as PDF
var docblob = doc.getBlob();
docblob.getAs('application/pdf').setName(doc.getName() + ".pdf");
folder.createFile(docblob);
}
如我所見,您正在使用onFormSubmit
觸發器。 此操作無法與用戶交互。
您可以嘗試向用戶發送帶有文件或下載鏈接的 email。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.