通过Google Apps脚本将图像添加到Google文档

ehf*_*eng 11 google-docs google-apps-script

如何通过Google Apps脚本将图像添加到Google文档(不是电子表格或演示文稿).我没有看到addImage方法.当然,球队不会把这个留下来.

http://code.google.com/googleapps/appsscript/class_document.html

Edu*_*rdo 11

来自文档:

function insertImage() {
  // Retrieve an image from the web.
  var resp = UrlFetchApp.fetch("http://www.google.com/intl/en_com/images/srpr/logo2w.png");

  // Create a document.
  var doc = DocumentApp.openById("");

  // Append the image to the first paragraph.
  doc.getChild(0).asParagraph().appendInlineImage(resp.getBlob());
}
Run Code Online (Sandbox Code Playgroud)

http://code.google.com/googleapps/appsscript/class_documentapp_listitem.html#appendInlineImage

我不确定你是否可以上传图片.但你确定可以通过网址将其插入段落中.