问题
A little info: I am using Google Forms, with Google Docs, and Google Spreadsheet. I have a Google Form which submits responses into a Google Spreadsheet. I also have a GAS with a function written for onFormSubmit, which takes the form submission and puts all the answers into a PDF template, and then emails the resulting PDF to my email address.
This is fine, however I would like to make the form also either:
A) Present a download of the PDF for the person who filled out the form
B) Automatically print the PDF (maybe using Google Cloud Print or something)
This is being used for fault reporting across a large company, and each person who fills out the form has to get a copy of the fault report to attach to the product, after they fill out the form.
My current script is available here: http://pastebin.com/0BrkLekX
回答1:
You can add this addition to your code to save a PDF file and present a link:
var form = FormApp.getActiveForm();
var folderID = "folder id here"; // Folder id to save in a folder.
var folder = DriveApp.getFolderById(folderID);
var newFile = folder.createFile(faultreport); //create file out of PDF
newFile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW); //make sure anyone can view
form.setConfirmationMessage("Print file here: " + newFile.getUrl()); //show a link to the file
Hope this helps.
来源:https://stackoverflow.com/questions/18305120/printing-downloading-from-google-forms