小编Wil*_*ker的帖子

将 google doc 转换为 pdf 会导致空白 pdf、google 脚本

这是我创建谷歌文档的代码,粘贴一些信息(最终来自电子表格),将其转换为 pdf 并通过电子邮件发送给我自己。

不幸的是,虽然驱动器中的文档具有“此文档是由 Google Apps 脚本创建的”。在其中发表评论,电子邮件中的 pdf 没有。它有正确的标题,但页面的内容丢失了。我已经尝试了几个关于堆栈溢出的例子,但到目前为止还没有一个可以工作。

var ss = SpreadsheetApp.getActive();

function onOpen(){
var ui = SpreadsheetApp.getUi(); 
ui.createMenu('TEST MENU') //creates main menu tab 
   .addItem('pdf', 'pdf') 
   .addToUi(); 
}

function pdf() {
  // Create a new Google Doc named 'Hello, world!'
  var doc = DocumentApp.create('Hello, world!');

  // Access the body of the document, then add a paragraph.
  doc.getBody().appendParagraph('This document was created by Google Apps Script.');

 var pdfContent = doc.getAs('application/pdf');
 var draftMail = GmailApp.createDraft('will@exampleEmail.co.uk',
                                   'Email title', 'Pls see attached', 
                                   {
                                     attachments: …
Run Code Online (Sandbox Code Playgroud)

javascript google-docs google-sheets google-apps-script

2
推荐指数
1
解决办法
1021
查看次数