Google apps script 如何在google文档中获取文本包装图像

Google apps script 如何在google文档中获取文本包装图像,google-apps-script,google-docs,Google Apps Script,Google Docs,由于现在的答案,我可以用正确的图像复制元素,但我发现了另一件事——如果图像作为“文本”插入,那么复制就做得很好。但是当我把它做成“文本包装”时,我根本找不到这个元素! 以下是测试代码: function test_show_all_structure_of_doc() { var final = 'final'; var doc = get_doc(working_directory, final); var body = doc.getBody(); var elements

由于现在的答案,我可以用正确的图像复制元素,但我发现了另一件事——如果图像作为“文本”插入,那么复制就做得很好。但是当我把它做成“文本包装”时,我根本找不到这个元素! 以下是测试代码:

function test_show_all_structure_of_doc() {
  var final = 'final';
  var doc = get_doc(working_directory, final);
  var body = doc.getBody();
  var elements = body.getNumChildren();
  for( var i=0;i<elements;i++) {
   var element = body.getChild(i).copy();
    var type = element.getType();
    if( type == DocumentApp.ElementType.PARAGRAPH ){
      Logger.log('paragraph' + i);
        var children = element.getNumChildren();

         if (children >0) {
           for (var j=0;j<children;j++) {
             var subelement = element.getChild(j).copy();
             var subtype = subelement.getType();
             Logger.log('subelement ' + j + ":"  + subtype);
             if (subtype == DocumentApp.ElementType.TEXT) Logger.log(subelement.getText());
           }
         }
     }
    else if( type == DocumentApp.ElementType.TABLE ){
      Logger.log('table');}
    else if( type == DocumentApp.ElementType.LIST_ITEM ){
      Logger.log('list item');}
    else if( type == DocumentApp.ElementType.INLINE_IMAGE ){
      Logger.log('inline image');}
     else {
      throw new Error("check what to do with this type of element : "+ type);
    }
  }
}
功能测试\u显示\u doc()的所有\u结构\u{
var final=‘final’;
var doc=获取文档(工作目录,最终);
var body=doc.getBody();
var elements=body.getNumChildren();
对于(var i=0;i0){

对于(var j=0;j来说,使用谷歌应用程序脚本(目前)是不可能的,并且是超过2年的目标

同时,仅支持