Google App脚本 - 在表单上显示PDF提交

时间:2013-06-12 18:42:00

标签: google-apps-script

我有一个当前的Google表单和应用程序脚本,其中Apps脚本正在获取表单数据,将其放入电子表格模板(进行一些计算),然后将该电子表格通过电子邮件发送为PDF。

Google Apps脚本中是否有办法在网络浏览器中显示此PDF而不是通过电子邮件发送?

1 个答案:

答案 0 :(得分:0)

您可以使用此workround

<强> 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();
}
相关问题