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

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

问题描述

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



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

解决方案

从文档:

 函数insertImage(){
//从网络中检索图像。
var resp = UrlFetchApp.fetch(http://www.google.com/intl/zh_CN/images/srpr/logo2w.png);

//创建一个文档。
var doc = DocumentApp.openById();

//将图像追加到第一段。
doc.getChild(0).asParagraph()。appendInlineImage(resp.getBlob());
}

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



I' m不确定您是否可以上传图片。但是你确定可以通过url将它插入到段落中。

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

解决方案

From the docs:

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

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天全站免登陆