通过 Google Apps 脚本将图像添加到 Google 文档 [英] Add images to Google Document via Google Apps Script

查看:41
本文介绍了通过 Google Apps 脚本将图像添加到 Google 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过 Google Apps 脚本将图像添加到 Google 文档(不是电子表格或演示文稿).我没有看到 addImage 方法.团队当然不会忽略这一点.

How can you add images to a Google Document (not Spreadsheet or Presentation) via Google Apps Script. I don't see an addImage method. Surely the team would not have left this out.

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

推荐答案

来自文档:

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());
}

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

我不确定您是否可以上传图片.但是你肯定可以通过一个 url 将它插入到一个段落中.

I'm not sure if you can upload an image. But you sure can insert it into a Paragraph via a url.

这篇关于通过 Google Apps 脚本将图像添加到 Google 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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