Google App脚本-在表单提交上显示PDF [英] Google App Script - Display PDF on Form Submit

查看:75
本文介绍了Google App脚本-在表单提交上显示PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前的Google Form和App Script,其中Apps Script接收表单数据,将其放入电子表格模板(进行一些计算),然后将该电子表格以PDF格式通过电子邮件发送.

I have a current Google Form and App Script where the Apps Script is taking the form data, putting it into a spreadsheet template (which does some calculations) then e-mails that spreadsheet as a PDF.

Google Apps脚本中是否有一种方法可以使该PDF显示在网络浏览器中,而不是通过电子邮件发送?

Is there a way in Google Apps Script to have this PDF displayed in the web browser rather than being sent in an e-mail?

推荐答案

您可以使用此 pag.html

<html>
<input type="submit" onclick="downloadPDF()"/>  
<a href="#" id="myDownloadLink" style="display:none">Click here to open</a>

<script>
  function sucess(e) {
   alert(e);
   var downloadLink = document.getElementById("myDownloadLink");  
   downloadLink.href=e;
   downloadLink.style.display = 'block';    
}

function downloadPDF() {
  google.script.run.withFailureHandler(alert).withSuccessHandler(sucess).getFile();
}
</script>
</html>

code.gs

function doGet() {
  return HtmlService.createHtmlOutputFromFile("pag");
}

function getFile() {
  return DriveApp.getFileById("1pczv0kRvgpI87owXWUXTtm4wXXsiG8-ErVWFtv05izI").getUrl();
}

这篇关于Google App脚本-在表单提交上显示PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆