Printing/Downloading from Google Forms

跟風遠走 提交于 2019-12-24 19:07:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!